Results 1 to 3 of 3
  1. #1

    Default Phone Number Validation (C#)


    Guyz help...I need a regular expression that can validate an international number.

    Acceptable formats

    (+63)-(123)-(234-5676)
    +63-123-234-5676
    +631232345676
    +1-1-234-5676

    Can anyone please tell me the regular expression for this...will really appreciate

  2. #2

    Default Re: Phone Number Validation (C#)

    Got It....If anyone needs it i have the code here it also includes email validation

    Code:
     public bool isEmail(string inputEmail)
            {
                //Checking for email validity
                //___________Local Part Valid Entries______________
                //Uppercase and lowercase letters
                //The digits 0 through 9
                //The characters , ! # $ % & ' * + - / = ? ^ _ ` { | } ~
                //The character "." provided that it is not the first or last character in the local-part
                //Local Part Regural Expression ^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*
    
    
                //___________Domain part valid entries__________________
                //Uppercase and lowercase letters
                //The digits 0 through 9
                //Regular Expression @[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$
    
                const string expression = @"^[a-zA-Z0-9_\+-]+(\.[A-Za-z0-9_\+-]+)*@[a-zA-Z0-9-]+(\.[A-Za-z0-9-]+)*\.([A-Za-z]{2,4})$";
                Regex regex = new Regex(expression);
                return regex.IsMatch(inputEmail);
            }
            public bool isNumber(string number)
            {
                const string expression = @"\(\+\d{1,4}\)\(\d{1,5}\)\(\d{3}-\d{4}\)";
                Regex regex = new Regex(expression);
                bool ans = regex.IsMatch(number);
                //string[] grp = regex.Split(number);
                //Console.WriteLine(grp.ToString());
                return ans;
            }
            public bool rareValid(string inputEmail)
            {
                const string expression = @"^[a-z0-9,!#\$%&'\*\+/=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%&'\*\+/=\?\^_`\{\|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,})$";
                Regex regex = new Regex(expression);
                return regex.IsMatch(inputEmail);
    
            }

  3. #3

    Default Re: Phone Number Validation (C#)

    Here is a version that only matches 10 digit phone numbers

    /(??:\+?1\s*(?:[.-]\s*)?)?(?\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})/

    Email validation

    "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$";

    C# email validation

    crow

  4.    Advertisement

Similar Threads

 
  1. The Corner Bakery: Phone Number?
    By anya in forum Food & Dining
    Replies: 19
    Last Post: 04-14-2011, 11:15 AM
  2. Need phone number of taxi company on cheating driver
    By pspoon_low-end in forum General Discussions
    Replies: 9
    Last Post: 01-26-2009, 11:48 PM
  3. Help! Need phone number of Jacobo's
    By malditangtisay in forum Food & Dining
    Replies: 0
    Last Post: 04-21-2008, 01:16 PM
  4. Replies: 2
    Last Post: 11-23-2007, 08:00 AM
  5. Need phone number sa dataventure.prob installing NFS.autorun error..
    By n-gageKID in forum Software & Games (Old)
    Replies: 6
    Last Post: 08-30-2007, 04:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top