0
RegExp in JS
someone explain to me what exactly is happening here... I understand what the regexp is finding but.. the part I can't wrap my brain around is the 2 parameters going into the function of the second part of the replace... https://code.sololearn.com/WWfo5Rj26eC3/?ref=app
1 ответ
+ 8
The second argument of the .replace() method is the text to be used for replacing the matching pattern OR a callback function returning the string to be use at each positive match (the regex used in your code example use 'g' flag to search for all match in the string, not the first one only;))...
You can get more information about how to use callback function as argument of .replace() method in the related documentation on MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter