Javascript string replacement and string segmentation sample code
- 2020-03-30 00:53:17
- OfStack
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)
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( ' -');