[Chicago-talk] Perl Style

Andy_Bach at wiwb.uscourts.gov Andy_Bach at wiwb.uscourts.gov
Mon Aug 23 11:31:18 CDT 2004

> except you left out \z vs. \Z.

Now, from the Owl book (Friedl "Mastering Regular Expressions"), I've
learned the /s can be called 'single mode' in that it affects a single
RE metachar, to wit the '.'  With "/s" the '.' will match the \n char.
That's it.  The "/m" can be called "multi mode" in that it affects 2
(aka "multiple") RE metachars, the caret and dollar sign.  In "/m" they
match on either side of a normal 'line' (the $/ (er, $\?) char, normally
\n) so that in a /g situation, for example, they'll match more than once
if you have multi-line input.  In the "/m" case \A and \Z can be used to
match the absolute string begin/string end *before the newline* 
- otherwise "^" is the same as "\A" and "$" is the same as "\Z" 

"\z" always matches the physical end of a string - that is, as opposed to 
'$' and '\Z' which match the end of a string if there is no newline in 
which case they match right before the final newline at the end of the 
string (unless in the /m
mode - in which case they match before *every* newline; see above ;-).


Andy Bach, Sys. Mangler
Internet: andy_bach at wiwb.uscourts.gov 
VOICE: (608) 261-5738  FAX 264-5932

"Whereof we cannot speak, thereof we should remain silent." L. 

More information about the Chicago-talk mailing list