in reply to Re^2: The "anchor" misnomer in regexes
in thread The "anchor" misnomer in regexes
However, if you use the /m regex modifier, then $ (but not \Z) changes to line-based semantics and essentially says “before the next newline or at the end of the string (whichever is first).”The choice isn't next newline or end of string and isn't whichever is first; regular leftmost/longest backtracking rules apply. So this:
gives 7, with the $ matching before the third-to-last newline. Same results without the ?.("\n" x 10) =~ /(\s+?$)\s{3}\z/m; print length $1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: The "anchor" misnomer in regexes
by Aristotle (Chancellor) on Dec 26, 2005 at 06:30 UTC |