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
  • 4,011
  • 8
  • 34
  • 55

1 Answers1

3

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

%s/\(\(href\|src\) *= *"[^"-]*\)-/\1_/g
perreal
  • 94,503
  • 21
  • 155
  • 181