mercredi 15 février 2017

jQuery regex to find string by substring

On my website I have multiple occurrences of a string with always the same substring (let's say "boo-foo", "loo-foo" and "great-foo").

I want to replace all of those with firstpart-foo. So the first part of all those should be bold.

Can anyone provide a regex for that in jQuery?

I believe it should look something like this, but with regex:

$(this).html($(this).html.replace("boo-foo","<strong>boo-</strong>foo"));




Aucun commentaire:

Enregistrer un commentaire