Reputation: 59
I would like to export some single tags that doesn't make sense in my text (exported from MS Word), such as:
<b stuff /> and <i stuff />.
I've tried the following regex:
/<b(.*?)\/>/i
But it doesn't work when I have something like:
<i>My text</i> some other text<i class="stuff" /> my final text.
Instead of getting only the single tag, it gets everything. How could I fix this, please? The final result must be:
<i>My text</i> some other text my final text.
UPDATE: aelor's answer was the closest to the one I needed. In the end, I mixed both aelor and Mikhail's answer to get this:
/(\s?)<[ib][^>]+\/>(\s?)/
Thanks!
Upvotes: 1
Views: 360
Reputation: 11116
search <[^>]+\/>
and replace with nothing.
demo here : http://regex101.com/r/xV4xX8
Upvotes: 2