vroom7 Posted March 10, 2006 Share Posted March 10, 2006 I am having some problems getting the right syntax for this. I need to replace any text between [b]<o: [/b]and [b]>[/b]. This is what I am trying, but I know the syntax is wrong:[code]$text = preg_replace('/\\<o:[^\\]]*\\>/', '', $text);[/code]Can anyone help me get this right?Basically I want to strip some html tags that Microsoft Word adds to it's text that look like this: [code]<o:BLAHBLAHBLAH />[/code] Link to comment https://forums.phpfreaks.com/topic/4640-preg_replace-and-wildcard/ Share on other sites More sharing options...
k.soule Posted March 11, 2006 Share Posted March 11, 2006 [code]$text = htmlspecialchars("<o:BLAHBLAHBLAH />");if(ereg('<o:(.*) />', $text)) { $text = str_replace("<o:", "", $text); $text = str_replace("/>", "", $text);}[/code]Maybe, it isn't as elegant as a single line replace, but it does the same thing. Sorry, I thought all you wanted to do was replace what was inside, in which case the solution was simple :o I don't know if you can match on something and replace on another match inside of the match. Link to comment https://forums.phpfreaks.com/topic/4640-preg_replace-and-wildcard/#findComment-16315 Share on other sites More sharing options...
wickning1 Posted March 11, 2006 Share Posted March 11, 2006 $text = preg_replace('/<o:.*?\/>/', '', $text); Link to comment https://forums.phpfreaks.com/topic/4640-preg_replace-and-wildcard/#findComment-16417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.