RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^\(0[1-9]{1}\)[0-9]{8}$
Description
This is used to validate an Australian telephone number with no other characters than the () being used. Validates area code being between 01 - 09.
Matches
(02)12341234 | (03)12341234 | (05)12341234
Non-Matches
00 1234 1234 | 00-1234-1234 | (00)12341234
Author Rating: The rating for this expression. Barry Pranklin
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Missing validating a heap of numbers
Name: Lloyd Borrett
Date: 2/2/2006 10:46:19 PM
Comment:
This expression doesn't handle all sorts of valid Australian phone numbers. To do that you need more than one regular expression. Something like... // // Function to check an Australian phone number is valid. // function is_valid_phone ($strPhone) { $isValid = false; // Strip blanks, brackets, periods, dashes and plus $strPhone = str_replace(array('(', ')', '-', '+', '.', ' '), '', $strPhone); // Check 10 or 11 digits switch (strlen($strPhone)) { case "6": if (ereg('^(13[0-9]{4})$', $strPhone)) { $isValid = true; } break; case "7": if (ereg('^(180[0-9]{4})$', $strPhone)) { $isValid = true; } break; case "10": if (ereg('^(((01|02|03|04|07|08|12|19)[0-9]{8})|(1300[0-9]{6})|(180[0-9]{7}))$', $strPhone)) { $isValid = true; } break; case "11": if (ereg('^(61(1|2|3|4|7|8)[0-9]{8})$', $strPhone)) { $isValid = true; } break; default: $isValid = false; } return $isValid; }


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials