somejkuser
somejkuser

Reputation: 9040

PHP Regex HTML Assistance

I need to write a regular expression using php which parses the following code block and removes all <font> and </font> tags.

<p align="left"><font face="Arial" size="1">February 22, 2007</font></p> <p align="left"><b><font face="Arial" size="4">2K Sports Announces Major League Baseball 2K7 Has Gone Gold </font></b></p>

Upvotes: 0

Views: 107

Answers (4)

Peter Bailey
Peter Bailey

Reputation: 105878

You don't need regex at all

echo strip_tags( $html, '<b><p>' );

Upvotes: 2

ty812
ty812

Reputation: 3323

$myString = preg_replace("/<([\/]*)font(.*?)>/","",$myString); should do the trick.

Edit: Just added some magic I forgot earlier... ashes upon me :)

Upvotes: 2

Matteo Riva
Matteo Riva

Reputation: 25060

$string = preg_replace('#</?font.*?>#', '', $string);

Upvotes: 0

camomileCase
camomileCase

Reputation: 1706

preg_replace('!</?font.*?>!', '', $string);

Upvotes: 1

Related Questions