It’s a simple question I guess 🙂
“bcd” regular expression pattern matches strings like “abcd” and “bcde”
how shall I modify this pattern to make it match only “bcde” pattern (not “abcd”, “1bcd”, “@3bcd”) ?
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 use the
^anchor to instruct the regex to start matching from the beginning of the string, so^bcdwill matchbcd,bcde,bcdef, etc but will not matchabcd,bc, etc.EDIT: I am not sure if you are after this, but, if you want the regex to match exclusively
bcde, you will have to use another anchor, this being the$in conjunction with the^anchor, so your regex will now become^bcde$. This will instruct the regular expression engine to start matching from the first character of the string and stop matching at the end of the string, so the regex^bcde$will match just the stringbcde, notabcde,bcdeg,abcdef, etc.