how can i exclude the $1 from the replace rule?
regex = new RegExp('hallo, test, blub', 'gi');
content = content.replace(regex,'<strong>$1</strong>');
alert('$1'); // dont work
Thanks in advance!
Peter
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
$1refers to the first group captured by the regex and is available only in the replacement string.For example, if content is
The score is 234and the regex isscore is (\d+), it will be replaced as<strong>234</strong>.If you want the value, you can use
content.match(regex)[1].