Re: regular expresion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



php wrote:
> I want to parse a html file
> for instance
>
> <body>
> <p>aaa jjjj mmmm dddd yyyy ssss</p>
> <b>aaa hhh mmmm dddd yyyy ssss</b>
> <p>aaa eee mmmm dddd yyyy ssss</p>
> <i>aaa kkkk mmmm dddd yyyy ssss</i>
> </body>
>
> and I want to create a regular expresion wich is able to extract entire
> text
> from enclosed tags WITHOUT a particular word
> for example               eee
> final I want to obtain this result
>
> aaa jjjj mmmm dddd yyyy ssss
> aaa hhh mmmm dddd yyyy ssss
> aaa kkkk mmmm dddd yyyy ssss

Use the built-in striptags to remove all the HTML.

Then, use explode("\n", $text) to find the line-breaks.

Finally, remove any line with 'eee' in it.

You could also do the explode first, then check for specific tags/lines
with 'eee' and drop those, and then re-assemble everything into a string,
and call striptags on that...  Not quite as clean and easy, though, but if
you can't identify the 'eee' part without the surrounding tags, you'll
need it.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux