Posted by Richard Lynch on 01/14/05 19:21
Jason Morehouse wrote:
> Simple enough, in theory... I need to match (count) all of the bold tags
> in a string, including ones with embedded styles (or whatever else can
> go in there). <b> and <b style="color:red">. My attempts keep matching
> <br> as well.
I think something not unlike:
'/<b( .*>|>)/'
The point being that you either have JUST '>' OR you have a SPACE and
whatever and '>'
I leave the capitalization and 'greedy' settings up to you.
The previous solution using '<b[^r]' will work only until the goofball
browser wars give us some other <bX> tag where X is a single character in
the alphabet.
There's a pretty cool Windows/Linux product a colleague swears by that's
called RegexCoach (?) which will not only let you try out
expressions/values and tell you which ones pass/fail, but you can
highlight sub-sections of the expression/values and see what it matches
piece by piece.
It's donationware -- try it out and donate the $20 (oooh, hurt me) if you
like it.
http://www.weitz.de/regex-coach/
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|