JavaScript – string regex backreferences

Like this:

str.replace(regex, function(match, $1, $2, offset, original) { return someFunc($2); })

Leave a Comment