Regex: How to specify captured group should contain a word

How to match anchor tag which has IDs attribute?

My string

<a href="something" id="someid" />
<a href="something" />

Expected output:

<a href="something" />
<a href="something" />

I need to delete id attribute in anchor tags.

I tried so far,

 <a(.*?)>  //how to specify `id` should be in the captured group

How to match anchor tag which has IDs attribute?
Note: I have not used DOM parser for this, as it saves as HTML


Source: regex

Leave a Reply