bsr
bsr

Reputation: 58682

Regex to modify an html tag

I am trying to replace

<legend>my legend</legend>

with

<legend><span>my legend</span></legend>

Intellij/Webstorm,supports regexp match and replace. I tried along the examples here, but didn't work. Any help on a regexp to find and replace as described above is appreciated.

I use mac, so gnu command line tools also an option (sed,..)

Thanks.

Upvotes: 0

Views: 279

Answers (1)

Mikhail Vladimirov
Mikhail Vladimirov

Reputation: 13890

Use replace with the following regular expression:

<legend>([^<]*)</legend>

and replacement

<legend><span>$1</span></legend>

Upvotes: 9

Related Questions