Re: run on regex line?
[email protected] (William Michels via perl6-users)
| Newsgroups | perl.perl6.users |
|---|---|
| Message-ID | <[email protected]> |
> On Jan 19, 2024, at 23:49, ToddAndMargo via perl6-users <[email protected]> wrote: > > Hi All, > > Can I do a run on line with a regex like I > just did with sed? > > $ zbarimg Screenshot.png | sed -e 's/.*?secret=//' -e 's/&.*//' > > Usually I just do two lines in Raku. > > Many thanks, > -T Hi Todd, Not that I am aware. The naive way is just to pipe them: ~$ echo 'roses are red' | raku -pe 's/roses/lilacs/' | raku -pe 's/red/blue/' lilacs are blue The Raku way would be combining those two statements into one Raku call: ~$ echo 'roses are red' | raku -pe 's/roses/lilacs/; s/red/blue/' lilacs are blue #OR ("big-S" notation below) ~$ echo 'roses are red' | raku -ne 'S/roses/lilacs/ andthen S/red/blue/.put' lilacs are blue The `andthen` call reloads the `$_` topic variable. For more examples, see: https://stackoverflow.com/questions/65066358/concatenating-s-in-raku HTH, Bill