RegExp with crlf?

<%

TestString = "[quote=Blah]Test" & vbCrLf & "Test[/quote]"

Set r = New RegExp
r.pattern = "\[QUOTE=(.*?)\](.*?)\[/QUOTE\]"
r.global = true
r.ignorecase = True
tmpRet = TestString

do
  RunRegExp = tmpRet
  tmpRet = r.replace(tmpRet, "<table border=""0"" width=""90%"" align=""center""><tr><td>&nbsp;<b>Quote </b>&nbsp;from $1</td></tr><tr><td><div class=""quote"">$2</div></td></tr></table>")
Loop Until RunRegExp = tmpRet

Set r = Nothing


Response.Write RunRegExp

%>

so the pattern as you can see is:"\[QUOTE=(.*?)\](.*?)\[/QUOTE\]"
and if I have a crlf in the string it does not work ... what do I have to change the pattern to, to make this work?
LVL 10
ThaSmartUnoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dmenardCommented:
Hello,

The dot matches any character, except "\n".

I write it from memory (can't test just now), but the following may work...

Try replacing every dot in yout regexp with (.|\n) :
"\[QUOTE=((.|\n)*?)\]((.|\n)*?)\[/QUOTE\]"

Or, even better, use a non capturing group (?:.|\n), so it won't interfere with what you already capture :
"\[QUOTE=((?:.|\n)*?)\]((?:.|\n)*?)\[/QUOTE\]"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ThaSmartUnoAuthor Commented:
now what would be different using the second one?

because they both work ... (i could have sworn i tried the first one, probably used []'s instead of ()'s)  
0
dmenardCommented:
The syntax (xxx) means a capturing match : everything between the parenthesis will be captured by the regexp engine, so you can use it later in the Matches collection or in a replacement.

The syntax (?:xxx) means a non capturing match : the parenthesis are just used to group something (. and \n in our case).

A non capturing match is more efficient (the engine do not need to store anything)

And least, as your pattern already contain capturing matches, I thought it would be best to not change the order of your captures :

In your original pattern : \[QUOTE=(.*?)\](.*?)\[/QUOTE\]
capture #1=what follow "="
capture #2=what is between ] and [

with the first syntax I proposed, capture #2 would become capture #3 or #4, with the second one, their order is unchanged.

so, use the second one : no change in the order and more efficient.
0
ThaSmartUnoAuthor Commented:
Oh i see ... thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.