Jump to content

Recommended Posts

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

[code]$text = htmlspecialchars("<o:BLAHBLAHBLAH />");
if(ereg('&lt;o:(.*) /&gt;', $text)) {
    $text = str_replace("&lt;o:", "", $text);
    $text = str_replace("/&gt;", "", $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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.