0

Hello
Anyone can help me derive a validation for French phone numbers, given the following:

String (max 255 chars)
French telephone formats (0123456789,
+33123456789, 0033123456789)

T.I.A.

2
Contributors
4
Replies
10
Views
4 Years
Discussion Span
Last Post by Ritesh_4
0

Are you looking for a Java-specific solution or something more general, eg a regular expression.
Are you just looking for the following rules:
( "0" OR "+33" OR "0033" ) followed by a non-zero digit, followed by exactly 8 digits, blanks to be ignored?
... if so it's the same pretty simple regex, whether you use that in Java or somewhere else.

Edited by JamesCherrill: corrected "9 digits" to "8 digits"

0

In fact its more the regular expression which am looking for, but which will cater for the three formats posted earlier...

0

You could play with something like this, which is just those simple rules:

        String regex = "(0|\\+33|0033)[1-9][0-9]{8}";
        String data = "0512345678";
        System.out.println(data + " is " + Pattern.matches(regex, data));
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.