MasterPtato MasterPtato -4 years ago 158
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 Source

you want to use a regular expression.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download