Simple Regular Expression Phone Number Validation in C# – Programming, Pseudocode Example, C# Programming Example
C# C# Console

Simple Regular Expression Phone Number Validation in C#

In almost all cases, it is recommended to validate the user input for several reasons (security, reliability, etc.). In this tutorial we will find out how to write a static class that can be applied for phone number validation in C #.

Example:
In this example, we can determine if the user entered a phone number in a common format including 0123456789, 012-345-6789, (012) -345-6789, (012) 3456789, 012 345 6789, (012) 345-6789, 012.345.6789 and all associated combinations.

If you want to use a regular expression to validate a phone number followed by the country code. For example, if you want to validate telephone numbers in France followed by +33, you can use the following regx:

To check :

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.