PatternRegex
Match a phone number
Find phone numbers in text without fighting every national format: an optional +, then digits with the separators people actually type.
Last updated
Matches
- +91 98765 43210
- (022) 2345-6789
- 9876543210
Doesn’t match
- 12345
- 1-800
- call me maybe
Why it’s written this way
Phone formats differ by country, by app and by the person typing — so instead of encoding one format, this encodes the shape all of them share: an optional +, a digit at each end, and 7-plus digits, spaces, dots, dashes or parentheses in between.
Anchoring both ends on \d stops the match from swallowing the trailing punctuation of a sentence, which is the usual failure of looser phone patterns.
Edge cases to know
- →It is a finder, not a validator — 999 999 9999 matches. Real validation needs a library that knows national numbering plans (libphonenumber) or an SMS to the number.
- →Short service numbers (100, 1930) are below the length floor by design; lower {7,} if you need them.
- →Long digit runs that aren't phones — order ids, timestamps — match too. Filter by context words (call, phone, mob) if your text mixes them.