brianlange Posted June 6, 2011 Share Posted June 6, 2011 I need a regular expression that will remove all span tags that have a font-family css declaration. <span style="font-family: Times New Roman;"> I could probably write this but I need to know how to also remove the closing </span> tag. Thanks, Brian Quote Link to comment Share on other sites More sharing options...
fugix Posted June 6, 2011 Share Posted June 6, 2011 note that $note will be the text that you are comparing preg_match_all('/<span style\=\"font\-family>(.*?)<\/span>/i', $note, $matches); Quote Link to comment Share on other sites More sharing options...
requinix Posted June 6, 2011 Share Posted June 6, 2011 My version is smarter but more complicated. $note = one two three four END; do $note = preg_replace('#]+style="[^"]*font-family:[^"]*"[^>]*>(([^#is', '$1', $oldnote = $note); while ($oldnote != $note); echo $note; Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted June 10, 2011 Share Posted June 10, 2011 Why not just remove the font-family from the style tag? If you would like to do that, just do something like this: $new_string = preg_replace("/font-family\:.+?;/i", "", $string); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.