I didn't know that but the string replace method support $X notation style and callback functions:
preg_replace in pure javascript:
preg_replace_callback in pure javascript:
Affichage des articles dont le libellé est php js. Afficher tous les articles
Affichage des articles dont le libellé est php js. Afficher tous les articles
PHP preg_replace the Javascript equivalent
It's seems that preg_replace (and apparently preg_replace_callback) doesn't exist in PHP.js or any other javascript library, however after some research I've found this one from Ferdinand Silva:
And this one from Xuan NGUYEN:
Problems
But their function don't support references (of the form \\n or (since PHP 4.0.4) $n or ${n}) in the remplacement argument . So I've developped mine !
Check my GitHub page for the PHP preg_replace Javascript Equivalent
And this one from Xuan NGUYEN:
Problems
But their function don't support references (of the form \\n or (since PHP 4.0.4) $n or ${n}) in the remplacement argument . So I've developped mine !
Check my GitHub page for the PHP preg_replace Javascript Equivalent