[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: regular expression

paul vudmaska

9/24/2003 1:41:00 AM

>>
--------------------
That's because '.' doesn't match newline by default.
To get it to,
you need to add the /m flag. (You also need to have
more than the one
line in the string, of course).

However, * is greedy, which means that given this
text:

Here is some [b]bold text[/b], and here is [b]some
more bold
text[/b]

Your regex will match all the way from the first [b]
to the last [/b],
rather than just to the first [/b]. You can prevent
that by using the
non-greedy qualifier ?, which goes after the *. Also,
I would use %r
instead of /.../ just to avoid one of those nasty
backslashes. :)
------------
<<

That great explanation and code worked like a champ.
Many thanks!

Paul



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder...