I’m trying to match only numbers and spaces in my php regex but the following fails and I can’t seem to understand why, can anyone shed some light on what I’m doing wrong please?
$pattern = '/^[0-9\ ]$/';
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.
Your regular expression just describes one single character. You might want to add a quantifier like
+:This describes a string of one or more digits or space characters.