I have an html tag as a string. If 'md' is included in the class attribute in this tag, I want to select it and get the expression in the tag.
Example:
'<tag class="...blah md blah...">(expression)</tag>
<tag></tag>
is first selector- Class attribute included
md
is second selector - At the same time, the tag should not be empty.
I mean, I need a regex that starts with <tag>
and ends with </tag>
and gives tag with md
in class attribute, but I couldn't get out of it.
What I did is trying to select those with direct md attribute, but this is wrong. Also problem with nested tag ones as well.
(<b md(?!<|>).+>|<b \S+ md>|<b md>|<b .+ md .+>)(.+)(<\/b>)
https://regex101.com/r/3Vv0WG/1
I decided that the correct form is in the class attribute, but I could not write this regex. Thanks for your help.
Example:
'<b class="... md ..."></b>'
not match because tag is empty'<i class="..."></i>'
not match because class attribute not include md<span class="...md...">ANYTHING</span>
match
It would be more appropriate not to be nested because it causes chaos in the code.