regex - Javascript replace function using regular expressions -
i trying use javascript's replace function replace string. replaces first instance. when use regular global expressions,
var result = 'moaning|yes you|hello test|mission control|com on'.replace(/|/g, ';');
i get: http://jsfiddle.net/m8uud/196/
i want get:
moaning;yes you;hello test;mission control;com on
simply escape pipe :
'moaning|yes you|hello test|mission control|com on'.replace(/\|/g, ';');
here you'll find list of regex special characters should escape.
Comments
Post a Comment