Copy link to clipboard
Copied
I want to use grep to format text between tags like this
<em>Something bold</em> some more text <em>another bit of bold</em>
<em>Something bold</em> some more text <em>another bit of bold</em>
So I used (<em>)(\w+)(</em>) with $2 to change it but ended up with this:
Something bold some more text <em>another bit of bold</em>
Something bold some more text <em>another bit of bold</em>
I cannot fathom why the command is not working on the second piece of bold text. Any help would be appreaciated.
Copy link to clipboard
Copied
Try the following expression
(?<=<em>).*?(?=<\/em>)
I don't think your expression would work at all. You have used \w which matches alphabets and numbers but you have spaces as well between your words so it won't work in my assessment.
See the expression working at the following link
https://regex101.com/r/PB82d2/1
-Manan