"foo = '@test.bar';\nfooa = @test.darn;".match(/@([a-z][a-z\.-_]*)/igm)
Why does this match
["@test.bar", "@test.darn;"]
rather than just
["@test.bar", "@test.darn"]
?
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.
In character classes, some letters have special meanings. The dot for example has none and does not need to be escaped. The minus in contrast defines a range of characters, and if you mean literally minus you need to escape it or put it in the end/beginning of the character class. Your range from
.to_actually includes./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_. You may want to use[a-z.\-_]or[a-z._-]instead.