I need to make little manipulation in the string. I need to retrieve the matched text and then replace the matched text. Something like this
Replace(“@anytext@”,@anytext@)
My string can have @anytext@ any where in string multiple times.
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.
You can make the second argument to
replacea function:That replaces the “one” with “ONE”. The first argument to the function is the matched result from the regex. The return value of the function is what to replace the match with.
If you have any capturing groups in your regex, they’ll be additional arguments to the function:
That does exactly what the first one does, but if you wanted to, you could see what was in the capturing groups. In that example,
group0would be “on” andgroup1would be “e”.