|
Posted by Bret Hughes on 01/14/05 03:56
On Thu, 2005-01-13 at 15:06, Jason Morehouse wrote:
> Hello,
>
> I normally can take a bit of regex fun, but not this time.
>
> 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.
>
interesting. I usually try to specifically describe in english what I
am looking for. in your case, I would say a string that begins with <
followed by zero or more spaces followed by a b or a B followed by zero
or more spaces followed by zero or more anything followed by >
/<\s*[bB]\s*.*>/
or perhaps it is enough to say match a < followed by 0 or more spaces
followed by a b or a B and not followed by a r or a R and followed by
zero or more anything followed by >
/<\s*[bB][^rR].*>/
These are untested but should be close and can be used in preg*
functions. the greedy matching might grab too much stuff and I always
forget how to do that when I hit it.
try them, let us see the results and we can get there
Bret
[Back to original message]
|