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] Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
wickning1 Posted March 11, 2006 Share Posted March 11, 2006 $text = preg_replace('/<o:.*?\/>/', '', $text); 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.