Getting phone numbers out of a supplier list, and what to check after
Say a colleague sends you a long email listing twenty suppliers, each with a name, an address, opening hours and a phone number, all as running text. You need the numbers in a sheet. Paste the email into the box and the numbers come out one per line, in the order they appear.
A short example shows what is found and what is not. The text "Call +44 20 7946 0958 or (555) 123-4567; not 2024-05-01." gives two numbers: +44 20 7946 0958 and (555) 123-4567. The date is skipped, because a date written year first with hyphens is a common shape that would otherwise slip in.
Phone numbers have no single shape. The United Kingdom groups digits one way, India another, and the United States puts the area code in brackets. A pattern loose enough for all of them will also catch some things that are not phone numbers, such as order numbers, tracking codes or long reference numbers with hyphens. That is why the result is a list to check, not a list to trust. The count line tells you how many were found, so you can compare it with the number of suppliers you expected.
The rules are simple to remember. A number needs 7 to 15 digits. It may start with + and a country code, and it may have an area code in brackets. Between two digits there may be at most one space, dot or hyphen. Anything joined to a letter, such as a model code like XR2000-15, is left out.
The limits are real, and worth saying plainly. Numbers written with letters, such as 1-800-FLOWERS, are not found. Short numbers such as 112 or 999 are below the 7-digit floor. Numbers with spaces around a hyphen, such as "020 - 7946 0958", are cut into pieces or missed. Extensions are dropped. And the tool cannot tell you whether a number is valid in its country or still in service. It finds the shape; you decide what it is.