Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement parsing of telephone numbers #3

Open
Simon-Laux opened this issue Jun 20, 2021 · 2 comments · May be fixed by #52
Open

Implement parsing of telephone numbers #3

Simon-Laux opened this issue Jun 20, 2021 · 2 comments · May be fixed by #52
Assignees
Labels
enhancement New feature or request

Comments

@Simon-Laux
Copy link
Member

maybe first only support +[country] [area] [number]?

@lk108
Copy link

lk108 commented May 1, 2023

That would be helpful for my use case.

@Simon-Laux
Copy link
Member Author

Simon-Laux commented Oct 31, 2023

android source code for this:

android/util/Patterns.java
    /**
     * This pattern is intended for searching for things that look like they
     * might be phone numbers in arbitrary text, not for validating whether
     * something is in fact a phone number.  It will miss many things that
     * are legitimate phone numbers.
     *
     * <p> The pattern matches the following:
     * <ul>
     * <li>Optionally, a + sign followed immediately by one or more digits. Spaces, dots, or dashes
     * may follow.
     * <li>Optionally, sets of digits in parentheses, separated by spaces, dots, or dashes.
     * <li>A string starting and ending with a digit, containing digits, spaces, dots, and/or dashes.
     * </ul>
     */
    public static final Pattern PHONE
        = Pattern.compile(                      // sdd = space, dot, or dash
                "(\\+[0-9]+[\\- \\.]*)?"        // +<digits><sdd>*
                + "(\\([0-9]+\\)[\\- \\.]*)?"   // (<digits>)<sdd>*
                + "([0-9][0-9\\- \\.]+[0-9])"); // <digit><digit|sdd>+<digit>

Looks there are also standards for it, like https://en.wikipedia.org/wiki/E.164

the German wikipedia page for telephone numbers also contains some example formats that are used in Germany, Switzerland and Austria: https://de.wikipedia.org/w/index.php?title=Rufnummer&oldid=236385081#Nationales

@Simon-Laux Simon-Laux self-assigned this Oct 31, 2023
@Simon-Laux Simon-Laux linked a pull request Nov 3, 2023 that will close this issue
6 tasks
@farooqkz farooqkz added the enhancement New feature or request label Apr 29, 2024
@farooqkz farooqkz changed the title [Idea] Implement parsing of telephone numbers Implement parsing of telephone numbers Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants