You are here: Re: [PHP] regex help « PHP « IT news, forums, messages
Re: [PHP] regex help

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация