Ukrainian mobile phone numbers can potentially start with a variety of prefixes, but they all have a total length of 12 digits. Here is a regular expression that matches Ukrainian mobile phone numbers:
index.tsx67 chars2 lines
Explanation of the regex:
^
- Start of string(
- Start of capturing group(\+38){0,1}
- Matches the optional '+38' international prefix for Ukrainian numbers0{0,1}
- Matches the optional leading zero in the local phone number format (XXX-XX-XX)[369]{1}
- Matches the first digit of the phone number, which can only be 3, 6, or 9\d{8}
- Matches the remaining 8 digits of the phone number, which can be any digit from 0 to 9)
- End of capturing group$
- End of stringHere's an example usage of this regex to validate a Ukrainian mobile phone number:
index.tsx204 chars7 lines
gistlibby LogSnag