|
|
 |
Re: FN-FORUM: Reg Expr: any character conundrum!
date posted 20th June 2007 00:31
----- Original Message -----
From: "Ben Johnson (Neogic) F" [EMAIL REMOVED]
/[.\n]+/ Match a mix of one or more chars incl. newlines (i.e., ANY
char)?
Wrong! The final example will not match across newlines. Try in your address
bar:
Unless you tell them otherwise, most regex engines will only look at one
line of text at a time. I don't know about javascript regex, but in perl,
/./s treats the entire input string as a single string, and then the . will
also match newlines.
Using /m will let $ (and ^) match before (after) any newline char. \z will
restrict to matching at the very end of the whole string - it's an anchor
like $; and \Z will match at the end of the string or before any newline.
The . metachar will not match a newline if you only have /m (it will if you
have /ms )
If you have the /s modifier turned on, [:cntrl:] will match a newline
(amongst other things).
Hope this helps - check out
http://www.regular-expressions.info/modifiers.html and
http://perldoc.perl.org/perlre.html . The bottom line is to try testing it
with your given retgex engine, sigh loudly, complain it doesn't work like
perl does, then try to find another way around the problem!!!!
Good luck,
Matt
|
 |
|