|
|
 |
RE: FN-FORUM: Reg Expr: any character conundrum!
date posted 20th June 2007 05:57
Hi Matt - thanks for replying.
Ben Johnson (Neogic) F wrote:
> /[.\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=20
Address bar ..
Matt wrote:
> Unless you tell them otherwise, most regex engines will only look at=20
> one line of text at a time. .. Using /m will let $ (and ^) match =
before=20
> (after) any newline char.
In JavaScript at least, matches can occur across lines without using the =
'm'
switch or similar (I believe this just changes the meaning of $ and ^). =
For
example:
/(.|\n)+/
DOES match anything across multiple lines. Both that and /[\s\S]+/ =
achieve
this (so I'm not stuck on a particular problem), but I'm just bemused by =
the
inconsistency that /[xy]+/ will match any mix of "x" and "y", but =
/[.\n]+/
doesn't match any mix of all characters and newlines (i.e., 'everything'
across lines) as one would expect.=20
Can't stand not understanding things that should be logical! Before you =
ask
- no, I don't iron my socks ;)
Any more ideas anyone?
Cheers, B
|
 |
|