Finding numbers in text

List the numbers on a company page

extractdigits
Find TEL and FAX numbers and drop duplicates written in other notations.
Try it
  • 03-5253-8111
  • 03-5253-8112
  • 092-513-5612

How it works

A page often shows the same number twice: once for domestic callers and once in international form. Use digits as the key to keep each number once.

extract does not tell TEL from FAX. When you need that, read the words just before each number in your own code.

In each language

import { extract } from "@kurashina-design/japan-phone";

// The contact section of a company page. The same number appears twice in different notations.
const page = `本社 TEL 03-5253-8111 / FAX 03-5253-8112
From overseas: +81-3-5253-8111
福岡支店 TEL 092-513-5612`;

const unique = new Map();
for (const number of extract(page)) unique.set(number.digits, number);
for (const number of unique.values()) console.log(number.national);

Output:

03-5253-8111
03-5253-8112
092-513-5612