Perhaps something like:
0([-\s]?\d){6,10}
So, a 0, followed by 6 to 10 groups of an optional space or dash followed by a digit.
Question
I'm trying to validate Swedish phonenumber using PHP's preg_match_all()
.
RegEx:
$pattern = '~(?>(\()?0\d(?(1)\))\s?+)?+\d\d\s?+(?>\d{3}\s?\d{3}|(?:\d\d\s??){3})~';
$haystack = 'bla bla bal 0701234567 bla 010-338000 bafdsa'; ...and so on..
Pattern should find:
Examples:
01-23456
012-34 56
012 34 56
01234567
0123-456789
Any suggestions?
Solution
Perhaps something like:
0([-\s]?\d){6,10}
So, a 0, followed by 6 to 10 groups of an optional space or dash followed by a digit.
OTHER TIPS
/^07(0|2|3|6|9)\d{7}$/g
this will work for the local number starts with the following initials: 070, 072, 073, 076, 079 Mobile phone networks example: 076xxxxxxx x will be the numeric