in reply to Re^4: \s does not match end-of-line
in thread /s does not match end-of-line
My personal regex best practices (solidly in line with TheDamian's as given in his PBP book) include reserving ^ $ for matching around embedded newlines (which means that the /m regex modifier is always asserted) and using \A \z \Z as "absolute" string start/end anchors. To the best of my recollection, \A \z \Z were introduced with Perl 5, sometime prior to 1996 (update: but see hippo's correction).
... is there something which "\Z" can do which "$" does not??
It's the other way around: ^ $ match also around embedded newlines (with the ever-present /m modifier), while \A \z \Z match only at string start/end; hence, in a sense, they do less. The advantage of this practice is that you never have to think about what ^ $ do; also, \A \z \Z cannot be modified.
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: \s does not match end-of-line
by hippo (Archbishop) on Feb 06, 2018 at 10:28 UTC |