What is the difference between encasing part of a regular expression in () (parentheses) and doing it in [] (square brackets)?
How does this:
[a-z0-9]
differ from this:
(a-z0-9)
?
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.
[]denotes a character class.()denotes a capturing group.[a-z0-9]— One character that is in the range ofa-zOR0-9(a-z0-9)— Explicit capture ofa-z0-9. No ranges.a— Can be captured by[a-z0-9].a-z0-9— Can be captured by(a-z0-9)and then can be referenced in a replacement and/or later in the expression.