MasterPtato MasterPtato - 22 days ago 6
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'?

Answer

you want to use a regular expression.

<(?!\*)
Comments