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
10/12/2009

preg_replace/preg_replace_callback PURE Javascript equivalent

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:

PHP preg_replace_callback Javascript equivalent

Usage:

[Explore Code] [Download @GitHub]
10/10/2009

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
»
 
 
Made with on a hot august night from an airplane the 19th of March 2017.