• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

find/change grep not working as expected

New Here ,
Feb 28, 2022 Feb 28, 2022

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.

TOPICS
How to

Views

35

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2022 Feb 28, 2022

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines