I was looking for the js equivalent for the PHP function preg_replace , and what I have found so far is just string.replace .
However, I'm not sure how to convert my regex to JavaScript. This is my PHP code:
preg_replace("/( )*/", $str, $str);
So, for example, the following:
test test test test
becomes:
test-test-test-test
Does anyone know how I can do this in JavaScript?
javascript php regex preg-replace
Skyfe
source share