PDA

View Full Version : Inclusion of Newlines in Groups...


SPG
06-09-2000, 05:18 PM
Okay, I'm stuck on this task -- how do I match a multiline as part of a preserved set of unknown?<BR><BR>Example:<BR>foo Ethel the aardvark was trotting<BR>down the riverbank one bright sunny morning bar<BR>.pattern = "(foo)(.*?)(bar)"<BR><BR>In the example, the pattern doesn't match because the . doesn't include matching the Newline (see http://www.builder.com/Programming/Scripter/050698/ref.html for a quick reference). Futhermore, for reasons I don't necessarily understand, alternately matching against whitespace ([s.], s|., etc) and/or setting the 5.5B2 "Multiline" to "true" doesn't fix this.<BR><BR>Any ideas, good or otherwise? (except for replacing the vbCrLfs out of existence in the first place... already thought of that, but I'd rather not mangle what I'm trying to preserve.)<BR><BR>Thanks!

SPG
06-12-2000, 12:02 PM
The following RegExp will store (in $1) the content of an HTML page (defined as "anything in body tags"):<BR><BR>[sS]*?<body[^>]*>([sS]*?)</body>[sS]*<BR><BR>Translated:<BR>Any number of spaces or non-spaces until<BR><body and anything until ><BR>Store any number of spaces or non-spaces until<BR></body> and any number of spaces or non-spaces<BR><BR>(the in </body> is because I was/am/ended up using the JScript RegExp engine.)

Duncan King
06-12-2000, 12:02 PM
Try:<BR><BR>.pattern = "(foo)([.
]*)(bar)"<BR><BR>The [.
] means "from range(any char execpt newline, newline)" so it should match anything...