This if condition:
if (preg_match('/^[a-zA-Z_]+\z/', $network_path))
Skips strings like:
bla-bla-bla-bla
How can I Improve this regex so it would accept strings like above.. ?
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.
This
[a-zA-Z_]is a character class. This construct matches one character from those defined inside the square brackets.So this class matches a to z, A to Z and the underscore. If you want to match also a dash, you just need to add it to the class. But be careful,
-is a special character inside a character class, so if you want to match it literally you need to escape it or put it to the start or the end of the class.or
or