On Wed, Jun 30, 2021 at 12:42 PM Nicholas Clark <nick@ccl4.org> wrote: > It seems that if $ is matched, it needs to be the (logical) end of the > pattern, else the entire pattern matches. By "logical", I mean that other > text follow in the regex, but it needs to be other alternations, or > something > else that doesn't contribute to matching. It can't be more characters, even > if they are present on the next line. > You can match more characters, but you need to consume the newline first. (The $ is a zero-width lookahead assertion – it does not consume anything.) eirik@rustybox[14:54:32]~$ perl use 5.16.0; for (qr'$\sbar'm, qr'$.*bar'ms) { say "foo\nbar" =~ $_ ? "Matched: $&" : "Nope" } __END__ Matched: bar Matched: bar eirik@rustybox[15:00:14]~$ basically, is there any string that qr'$foo'm will match? > No, no more than there is a string that qr/(?=bar)foo/ will match. Need to consume that bar first. EirikThread Previous | Thread Next