DEV Community

Discussion on: A regex cheatsheet for all those regex haters (and lovers) 👀

Collapse
 
konkretnekosteczki profile image
KonkretneKosteczki

If you are adding usefull regex functions at the end of the code, you could also add information on replace function taking a callback as an argument.

const p = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?';
p.replace('dog', (match, matchIndex, originalString) =>{
return match+"test"+matchIndex // match based replacer
})