Javascript string replacement and string segmentation sample code


JS string replacement function (sort of like PHP’s preg_replace)

STR. Replace (’ XXX ’, ‘yyyy’); Replace the first one STR. Replace (/ XXX/g, ‘yyyy’); Replace all

String splitting (similar to PHP’s splitting function)


var test =  ' a-b-c-d';
test.split( ' -');