I want to match this :
- eight(8) alphanumeric characters
- followed by – hyphen
- followed by twentytwo(22) alphanumeric characters, here is what I tried and its not matching :
[8]\w+-[22]\w+
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.
Should be:
[8]matches a single character – the literal 8, and[22]matches one literal 2.Note that
\walso allows the underscore. If that is a problem, useA good tip from Tim, if you want tp capture the pattern from a file or string, you probably want to add
\b– word boundary, to avoid partial matching. For example, if you wanted a 2-4 format12-1234, the first parrent will match1234-1234567: