why this snippet:
'He said "Hello"' =~ /(\w)\1/
matches "ll"? I thought that the \w part matches "H", and hence \1 refers to "H", thus nothing should be matched? but why this result?
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.
\wmatches any alphanumerical character (and underscore). It also happens to matchHbut that’s not terribly interesting since the regular expression then goes on to say that this has to be matched twice – whichHcan’t in your text (since it doesn’t appear twice consecutively), and neither is any of the other characters, justl. So the regular expression matchesll.