Return to Snippet

Revision: 16104
at July 27, 2009 06:16 by funkadelicsoul


Initial Code
var term = 'Valves';
var value = 'Foo Foo Valves Blah Yo Yo';

var regex = new RegExp(term,'ig');

var replaced = value.replace(regex,'<span>$&</span>');

alert(replaced); //Foo Foo <span>Valves</span> Blah Yo Yo

Initial URL

                                

Initial Description

                                

Initial Title
Regular Expression Wrap

Initial Tags
regex

Initial Language
JavaScript