1

Can you advise me a regexp to replace - to _ in my HTML file but focus on href and src attributes only (I don't need to make any changes to contents of my Web page).

For instance:

Before:

<a href="my-profile.html">PLF Series</a>
<img src="images/my-sample.jpg">

After:

<a href="my_profile.html">PLF Series</a>
<img src="images/my_sample.jpg">
fronthem
  • 3,855
  • 6
  • 31
  • 52

1 Answers1

3

This one needs to be repeated until there is no match:

%s/\(\(href\|src\) *= *"[^"-]*\)-/\1_/g
perreal
  • 90,214
  • 20
  • 145
  • 172