On 10/26/25 8:51 PM, William Michels wrote:
In the Raku REPL:
[0] > .Str.say for "first line\nsecond line" ~~ m:g/ ^ \w+ /
first
[0] > .Str.say for "first line\nsecond line" ~~ m:g/ ^^ \w+ /
first
second
[0] > .Str.say for "line first\nline second" ~~ m:g/ \w+ $ /
second
[0] > .Str.say for "line first\nline second" ~~ m:g/ \w+ $$ /
first
second
HTH, Bill.
On Oct 26, 2025, at 14:50, ToddAndMargo via perl6-users <perl6-
[email protected]> wrote:
On 10/26/25 7:56 AM, William Michels wrote:
^^ has the regex meaning "start-of-line"
$$ has the regex meaning "end-of-line"
Compare to:
^ has the regex meaning "start-of-string"
$ has the regex meaning "end-of-string"
If you're analyzing input linewise (for example using a one-liner
with `-ne` or `-pe` flags),
then start-of-line equals start-of-string, and end-of-line equals
end- of-string.
HTH, Bill.
Can I talk you out of a few examples?
Hi Bill,
Thank you!
Would you double check my understanding?
-T
Extract the first (^) word (\w+) from the first line
[0] > .Str.say for "first line\nsecond line" ~~ m:g/ ^ \w+ /
first
Extract the first (^^) word (\w+) from all the lines
[0] > .Str.say for "first line\nsecond line" ~~ m:g/ ^^ \w+ /
first
second
Extract the last ($) word (\w+) from the last line
[0] > .Str.say for "line first\nline second" ~~ m:g/ \w+ $ /
second
Extract the last ($$) word (\w+) from all the lines
[0] > .Str.say for "line first\nline second" ~~ m:g/ \w+ $$ /
first
second