I have this following regex, starts with 09 and has a 2 digit number that should be only in some specific numbers, then 7 digits:
^[0][9](11|12|13|14|15|16|17|90|91|92|93|94|30|33|35|36|37|38|39|01|02|03|04|05|41|20|21|22|32|31|34|42)[0-9]{7}$
Or in python:
numbers = r"11|12|13|14|15|16|17|90|91|92|93|94|30|33|35|36|37|38|39|01|02|03|04|05|41|20|21|22|32|31|34|42"
phone_number_regex = rf"^[0][9]({numbers})[0-9]{7}$"
Is there a way to make this regex shorter? there is too much |s.
>Solution :
Looking at the alternatives, it seems the following matches the same things:
^09(0[1-5]|1[1-7]|2[012]|3[0-9]|4[12]|9[0-4])[0-9]{7}$