Jericho
Jericho

Reputation: 81

Remove HTML tags with specific content using Regex

I want to remove an HTML tag but only with specific content is appear, like this:

<strong>\u00a0</strong>

I want to remove the tag only if \u00a0 is appearing inside the tag. Any solution?

Upvotes: 0

Views: 29

Answers (1)

swingbit
swingbit

Reputation: 2745

If what you mean is to match the exact string \u00a0, then the regex is just about escaping a couple of slashes:

s/<strong>\\u00a0<\/strong>//g

Or, more readable:

s|<strong>\\u00a0</strong>||g

If you mean to match the actual unicode character U+00A0, then the regex is:

  • Non-PCRE syntax:
s/<strong>\u00a0<\/strong>//g
  • PCRE syntax:
s/<strong>\x{00a0}<\/strong>//g

Upvotes: 1

Related Questions