In Ukraine, as of 2020, there are three major mobile operators and three smaller ones.
For a complete understanding of what is described below, I will clarify a few points right away.
Python version 3 is used, and accordingly, the regular expressions will be for this version; I do not know if it will work with previous versions.
The built-in library re will be used for working with regular expressions.
X — any digit
phone — phone number in the format 380XXXXXXXXX
Codes and regular expressions for Python for major operators:
Kyivstar:
Mobile network codes — 067,068, 096, 097, 098. Number of subscribers — 26.4 million (in the third quarter of 2019).
| Code | Full number | Regular expression |
|---|---|---|
| 098 | 38098XXXXXXX | re.match(r'^38098[0-9]{7}$', phone) |
| 097 | 38097XXXXXXX | re.match(r'^38097[0-9]{7}$', phone) |
| 096 | 38096XXXXXXX | re.match(r'^38096[0-9]{7}$', phone) |
| 068 | 38068XXXXXXX | re.match(r'^38068[0-9]{7}$', phone) |
| 067 | 38067XXXXXXX | re.match(r'^38067[0-9]{7}$', phone) |
Regular expression for identifying the Kyivstar operator considering all its codes:
re.match(r'^3806[7,8][0-9]{7}$|^3809[6-8][0-9]{7}$', phone)
Lifecell:
Mobile network codes — 063, 073, 093 . Number of subscribers — 6.9 million subscribers (in the third quarter of 2019).
| Code | Full number | Regular expression |
|---|---|---|
| 063 | 38063XXXXXXX | re.match(r'^38063[0-9]{7}$', phone) |
| 073 | 38073XXXXXXX | re.match(r'^38073[0-9]{7}$', phone) |
| 093 | 38093XXXXXXX | re.match(r'^38093[0-9]{7}$', phone) |
Regular expression for identifying the Lifecell operator considering all its codes:
re.match(r'^380[6,7,9]3[0-9]{7}$', phone)
Vodafone (MTS):
Mobile network codes — 050, 066, 095, 099 . Number of subscribers — 19.6 million subscribers (in the first quarter of 2019).
| Code | Full number | Regular expression |
|---|---|---|
| 050 | 38050XXXXXXX | re.match(r'^38050[0-9]{7}$', phone) |
| 066 | 38066XXXXXXX | re.match(r'^38066[0-9]{7}$', phone) |
| 095 | 38095XXXXXXX | re.match(r'^38095[0-9]{7}$', phone) |
| 099 | 38099XXXXXXX | re.match(r'^38099[0-9]{7}$', phone) |
Regular expression for identifying the Vodafone (MTS) operator considering all its codes:
re.match(r'^38050[0-9]{7}$|^38066[0-9]{7}$|^3809[5,9][0-9]{7}$', phone)
Trimob:
Mobile network code — 091. Number of subscribers — 250 thousand (as of April 20, 2018).
| Code | Full number | Regular expression |
|---|---|---|
| 091 | 38091XXXXXXX | re.match(r'^38091[0-9]{7}$', phone) |
Regular expression for identifying the Trimob operator considering all its codes: