You are here: Re: preg_match and html question « PHP Programming Language « IT news, forums, messages
Re: preg_match and html question

Posted by gosha bine on 06/11/07 12:50

On 10.06.2007 17:23 Sam Waller wrote:
> I need a regular expression for preg_match to find all of the strings between
> '>' and '<' from html. Eg.
>
> 1. <TD><FONT SIZE='2'>XXX</FONT></TD>
> 2. <TD><FONT SIZE='2'><A HREF=http://www.whatever.com/...7>ZZZ</A></FONT></TD>
> 3. <TD ALIGN=CENTER><FONT SIZE='2'>Y/Y</FONT></TD>
>
> #1 matches should be "", "XXX", and ""
> #2 should be "", "", "ZZZ", "", ""
> #3 should be "", "Y/Y", ""
>
> Actually I need only the non-empty strings, but I can just ignore the empty ones.
>
> I've tried preg_match("/>(.*)</i", $str, $matches) but it doesn't work like I want.
> Does anyone know how to get this to work?
>
> thanks,
> Sam
>

Try using a character class instead of dot: />([^<>]*)</

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

 

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

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