javascript - What is the meaning of this regular expression in java script -
what meaning of expression. unable understand ?
function escaperegexp(string){ return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1"); }
this has function of introducing backslash character \ before characters in regular expression set [...].
the characters are: . * + ? ^ = ! : $ { } ( ) | [ ] / \
note of these escaped \ because have special meaning within context of regular expression, /, , within set, ].
the outer brackets in regular expression have effect of "capturing" resulting match, , in second argument function, $1 result of capture. /g option means repeat "globally", or many times match.
Comments
Post a Comment