Page 1 of 1

Regular Expression

Posted: Mon Nov 24, 2014 8:31 pm
by pedrazzani
hello ,

I'm using regular expressions, but the code does not work in SwitchScripter. Follows the code.





var re = /(w+)s(w+)/;

var str = "John Smith";

var newstr = str.replace(re, "$2, $1");

job.log(3,newstr);



output -> "$2, $1"






Best Regards



Marcelo Pedrazzani

Regular Expression

Posted: Tue Nov 25, 2014 12:51 am
by dkelly
Try



var str = "John Smith";

var newstr = str.replace(/(w+)s(w+)/g, "2, 1");

job.log(3,newstr);

Regular Expression

Posted: Tue Nov 25, 2014 1:36 pm
by pedrazzani
Thank you . It worked very well.



Marcelo Pedrazzani.