Skip to content

Instantly share code, notes, and snippets.

Created August 24, 2012 09:20
Show Gist options
  • Select an option

  • Save anonymous/3448048 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/3448048 to your computer and use it in GitHub Desktop.
var re
, match
, html
, new_string;
re = /<a href=".*?">([^<]+)<\/a>/g;
html = 'Testing <a href="http://google.com">a_b_c_d</a><a href="http://google.com">x_y_z/a><a href="http://google.com">1_2_3_4</a>';
new_string = html.replace(re, function(a, b) {
return a.replace(/_/g, "-");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment