I have this regex:
preg_match("#^([0-9]+)$#", $post['telephone'])
who allow only numbers (for a phone number in the French type so 0123456789) but I would like to allow spaces. For example allow this type of string: "01 23 45 67 89".
Can you please help me?
If you want to have exactly 8 digits, e.g., but still allow for arbitrary number of whitespace characters, the following is great:
^(?:\s*\d){8}$
Or, if you want to allow dashes too:
^(?:\s*-*\s*\d){8}$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With