Validating in vb net
Letters, numbers, and underscore are all considered word characters (see Recipe 2.6).
Note that the first word boundary token appears after the optional, opening parenthesis.
As we’ve repeatedly seen, parentheses are special characters in regular expressions, but in this case we want to allow a user to enter parentheses and have our regex recognize them.
⋯ # [Match the remaining digits and separator.] $ # Assert position at the end of the string..
If you want to limit matches to valid phone numbers according to the North American Numbering Plan, here are the basic rules: Beyond the basic rules just listed, there are a variety of reserved, unassigned, and restricted phone numbers.
Unless you have very specific needs that require you to filter out as many phone numbers as possible, don’t go overboard trying to eliminate unused numbers.
See Recipes 3.5 and 3.15 for help implementing this regular expression with other programming languages. Character classes allow you to match any one out of a set of characters.New area codes that fit the rules listed earlier are made available regularly, and even if a phone number is valid, that doesn’t necessarily mean it was issued or is in active use.Two simple changes allow the previous regular expression to match phone numbers within longer text: matches the position between a word character and either a nonword character or the beginning or end of the text.Since a question mark is used after each separator, the phone number digits are allowed to run together.Note that although this recipe claims to handle North American phone numbers, it’s actually designed to work with (NANP) numbers.