MasterPtato MasterPtato - 5 months ago 60
Javascript Question

Replace word wrap

Is there a way to use the javascript replace function to only wrap around one instance? For example, if I had

var string = '**blah*';
string = string.replace('*', 'text').replace('*', 'word');

This would make the string 'textwordblah', but is there a way to make it 'text*blahword'?


you want to use a regular expression.