Jump to content

Regex similar to strip_tags() but with added functionality


OsvaldoM

Recommended Posts

I'm a very basic user of regex and I bumped into a problem in which im a bit lost...

I have a piece of text that comes with html tags and then through Solr it receives 2 custom tags to highlight words (<em> & <b>).

My main problem is that i want to keep Solr's html tags but skip the rest and cleaning up the text before supplying it to Solr is not posible due to search configurations...

So I want to keep something like

 

"this is normal text <em><strong>myText</strong></em> and in here it continues"

 

but skip all other html tags (including <strong> and <em> but that are not next to each other...)

So this text:

 

<strong>To be</strong> or <em><strong>not to</strong</em> <em>be</em>

 

Should be stripped into this:

To be or <em><strong>not to</strong</em> be

 

Help would be highly appreciated!.

 

 

Link to comment
Share on other sites

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.