Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I use Regex to check if multiple strings appear at the start of a phone number

I’m trying to check if a phone number has either of the following 031, 039, 076, 077, 078 at the start. I’m able to check if one of them occurs once
(096){1} but not able to check the input if any of them occur at least once.
How would I check if any of the sequences appear ?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You may use an alternation here. Assuming the phone numbers were all digits, and you had no other requirements, you could use:

^(?:031|039|076|077|078)\d+$
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading