Regular Expression

Post Reply
pedrazzani
Newbie
Posts: 3
Joined: Tue Aug 19, 2014 2:50 pm

Regular Expression

Post 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
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Regular Expression

Post by dkelly »

Try



var str = "John Smith";

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

job.log(3,newstr);
pedrazzani
Newbie
Posts: 3
Joined: Tue Aug 19, 2014 2:50 pm

Regular Expression

Post by pedrazzani »

Thank you . It worked very well.



Marcelo Pedrazzani.
Post Reply