views:

35

answers:

1

I have the following function:

listorder = listorder.replace('projectlist-','');

Problem with this is it only finds and replace the first instance and there are many. How can this be updated to Find/Replace All instances in the string?

Thanks

+6  A: 

Global replace (all instances)

listorder = listorder.replace(/projectlist-/g,'');

Case-insensitive replace

listorder = listorder.replace(/projectlist-/i,'');

Global and case-insensitive

listorder = listorder.replace(/projectlist-/gi,'');
Ben