I am facing a little problem.
My string is From {start} to {end} and I want to validate it using preg_match() to avoid illegal chars.
preg_match("/^[a-zA-Z\{\} ]{1,}$/",$var)
The point is the escape for { and }.
thanks 🙂
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 don’t need to escape curly braces inside the square brackets:
If you need to escape characters, just put a backslash (
\) before them. Note: if you’re using a double quoted string, you may need to escape the backslashes from interpretation there. For example:'\t'matches a tab character;"\t"is a tab character; and"\\t"is equivalent to ‘\t’.