0

I would like to check for a string that MUST have numbers and COULD have space, - and + (optionally). Anything else should not be allowed.

I tried it with the following code but I think there must be something wrong with my Regex:

$phone = 2454212154;
if (!preg_match('[\s0-9+-]', $phone)) {
    echo 'error';
}

0 Answers0