I am trying to use regular expressions in JavaScript to test if the value of a form text input is a French mobile phone number.
French mobile phone numbers begin with
06
or07
and are followed by 8 digits, like these :0611223344
or0744332211
. The international form of these numbers begin with+33
which replaces the first0
, like these :+33611223344
or+33744332211
.
I am using this RegEx : (\+\b33|\b0)[67][0-9]{8}\b
, which tests if the input begins with +336/7 or 06/7 and is followed by 8 digits.
I added the Word Boundary (\b
) so numbers like 06112233440611223344 (two concatenated correct forms) don't match.
This RegEx works fine for thoses cases :
0611223344 // matches
0744332211 // matches
+33611223344 // matches
+33744332211 // matches
06112233440744332211 // doesn't match
But I still encounter problems with these inputs :
+33611223344+33611223344
0611223344 0744332211
0744332211+33611223344
0744332211 +33611223344
They all match...
I tried to add ^
and $
in all possible ways to my RegEx, but whenever I add one of these symbols, the RegEx doesn't work anymore.