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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -