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!.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.