CancelImage Upload

Topics: Regular Expressions
Read our latest entries.
Posted by Garren Harland on September 16, 2009, 1:24 pm.
At the age of 16 years, every citizen in the Republic of South Africa is issued an identity document, which is a passport sized 8 page booklet. Inside this passport is the individual's national identification number, and this page discusses how it's format can be validated using regular expressions.
Click here to read on.
Posted by Garren Harland on September 16, 2009, 12:33 pm.
New Zealand's National Health Index Number primarily servers the puropse of providing a unique ID Code for individuals within the country's health system. Format wise it consists of 7 characters, the first 3 being alphanumeric, while the last 4 are numbers.
Click here to read on.
Posted by Garren Harland on September 16, 2009, 11:56 am.
The Permanent Account Number (PAN) is India's equivalent of a National Identification Number. It is a 10 Symbol code that is issued to all taxpayers by the Indian Income Tax Department. It is a standard requirement for opening bank accounts, the instalment of a personal phone line, and receiving a salary. Naturally it's main purpose is to help prevent tax evasion.
Click here to read on.
Posted by Garren Harland on September 16, 2009, 11:21 am.
As you are probably aware the US equivalent of a national identification number is the Social Security Number. This 9 digit number is issued by the Social Security Administration of the United States Government. Usually this number is applied for by parents soon after a child's birth.
Click here to read on.
Posted by Garren Harland on September 5, 2009, 12:44 pm.
Validating a phone number is easy. That is if you merely want to make sure that the user has indeed entered a number, and not used any alphanumeric letters.
Click here to read on.
Posted by Garren Harland on August 30, 2009, 8:47 pm.
The following page discusses how regular expressions can be used to validate the British National Insurance Number, which is allocated to ever UK resident within the United Kingdome upon their 16th birthday. This number is usually received in a card format, containing a 9 digit code, consisting of the following format, 2 letters, 6 numbers and then to finish another letter.
Click here to read on.
Posted by Garren Harland on August 18, 2009, 1:06 pm.
Ever asked yourself what the difference is between functions that start with the term ereg and eregi? After all, both search through strings by using regular expression patterns. Both either return true or false and pass on groups in arrays of regs (ereg and eregi), or perform a replacement in the specified location without changing the original (ereg_replace and eregi_replace).
Click here to read on.
Posted by Garren Harland on August 18, 2009, 11:20 am.
The PHP function sql_regcase() is ideal for regular expression newbies, as it converts any search patter with which it is provided into something a regexp function can use to analyse strings with.
Click here to read on.
Posted by Garren Harland on August 17, 2009, 7:28 pm.
Sometimes a string comes along that requires more than the traditional PHP split() function. Let us say for example we had multiple conditions by which a string needed to be split up by. In some instances a mere space would be enough, yet, the string should also be split up at each comma. Here then clearly a preg_split() is required.
Click here to read on.
Posted by Garren Harland on August 17, 2009, 6:43 pm.
Every asked yourself whether or not a symbol within a regular expression required a backslash, in order for the syntax to work? After all, there are quite a few symbols to keep track of in regards to regular expressions. Especially to programming newbies distinguishing between the two can be a daunting task.
Click here to read on.
Posted by Garren Harland on August 5, 2009, 10:28 pm.
On a dynamic website, such as a form, users often get the feeling they can post all kinds of dodgy images to their heart's desire. Now while most webmasters would either A. Let their visitors have their fun, or B. Go nuclear, and ban their visitors from interacting with HTML code, there is another way.
Click here to read on.
Posted by Garren Harland on August 3, 2009, 3:13 pm.
Sometimes all you need from a string are certain elements. Such an element can be a hidden number which has significance to you. Maybe a timestamp for instance.
Click here to read on.
Posted by Garren Harland on August 3, 2009, 2:22 pm.
In Latvia Postcodes consist of two letters followed by a hyphen and four digits.
Click here to read on.
Posted by Garren Harland on August 3, 2009, 1:56 pm.
Japan's postcodes consist of 7 digits, grouped into 3 and 4 digit cluster separated by a hyphen. Here for instance is what Chiyoda in Tokyo's Postcode looks like.
Click here to read on.
Posted by Garren Harland on August 3, 2009, 11:44 am.
If you have a string that can only contains alphanumeric values, it is a lot simpler to state the type of characters that are allowed, instead of looking up every possible symbol on the planet and banning it.
Click here to read on.
Posted by Garren Harland on July 30, 2009, 8:03 pm.
One of the most powerful functions in php is eregi_replace(). By using this function effectively with good regular expression syntaxes you can manipulate strings to your heart's desire. On this page we will cover to simple examples as an introduction to eregi_replace(). If you have not worked with regular expressions before, you should definitely read the introduction to regular expressions tutorial before attempting the following examples.
Click here to read on.
Posted by Garren Harland on July 29, 2009, 6:31 pm.
Brazil has a nationwide scheme known as Codigo de Enderecamento Postal (CEP), which has been running since 1972 and consists of 5 digits. Thanks to economic groth however a three digit suffix has been added to the CEP since 1992. This gives Brazilian Postcodes the following format.
Click here to read on.
Posted by Garren Harland on July 29, 2009, 3:07 pm.
To validate a South African Postcode we need to devise a Regular Expression that validates numbers from the range of 0001-9999. For elegance sake I will split the following example into two parts. First to check that the user has not entered 0000, and then to validate that indeed four digits have been entered. Here are the two regular expressions we will use.
Click here to read on.
Posted by Garren Harland on July 29, 2009, 1:15 pm.
China's Postal codes consist of 6 digit number system which is applicable for the whole country. Since the lowest range belonging to Taiwan (000000???009999) can consist of six zeroes (although the lowest code in this regard probably has five zeroes: 000001), the resulting regular expression code is not very long. In fact all that needs to be done, is the specification that six ({}) digits ([0-9]) are required.
Click here to read on.
Posted by Garren Harland on July 29, 2009, 11:51 am.
Indian postal index numbers are 6 digit numbers, and therefore putting together a Regular Expressions statement to validate them does not require to much work. Our statement will consist of two parts, the first consisisting of numbers ranging from 1-9, the second, consisting of 5 digits will be 0-9.
Click here to read on.
Posted by Garren Harland on July 29, 2009, 10:59 am.
While the code below uses JavaScript to demonstrate a HTML Color Code validation, the regular expression itself should work in a variety of programming languages, including server side languages such as PHP.
Click here to read on.
Posted by Garren Harland on July 29, 2009, 9:17 am.
Because New Zealand Postcodes are a simple 4 digit number their validation is very simple, as the following regular expressions goes to show. Note that the regular expression itself should be usable by a number a programming languages! Here is what it looks like.
Click here to read on.
Posted by Garren Harland on July 28, 2009, 3:23 pm.
People in general are not very smart when it comes to inventing passwords. It is shocking how many of us actually believe using a family members' name, date of birth, wedding date, wife or pet's name, favourite sports team, etc are secure choices!
Click here to read on.
Posted by Garren Harland on July 13, 2009, 7:05 pm.
Date of birth inputs come in various shapes and sizes. To fit these various requirements I have put together 6 different Regular Expressions for the various styles. I am sure if there is not one there to fit your required criteria you can mix and match to come up with the desired result!
Click here to read on.
Posted by Garren Harland on July 11, 2009, 5:38 pm.
Are you tired of having to type [a-zA-Z0-9] every time you want your regular expressions to look for alphanumeric symbols? Then you are not alone! Thankfully an alternative method exists to address various shapes and forms of symbols in regular expressions.
Click here to read on.
Posted by Garren Harland on July 7, 2009, 7:23 pm.
There are two ways to build a regular expression to validate Australian Post Codes. There is the easy way which will check that at least the format is right, and then there is the hard way to make sure the postcode entered is within the correct postcode range following the state abbreviation code.
Click here to read on.
Posted by Garren Harland on July 7, 2009, 12:51 pm.
Since US Zip Codes consist of numeric values they are pretty simple to validate with regular expressions. What is important is that the Zip + 4 format is taken into account.
Click here to read on.
Posted by Garren Harland on July 7, 2009, 12:03 pm.
Here is a tutorial for those of you wishing to validate SWIFT and BIC Codes using JavaScript by using Regular Expressions. I have already written a similar tutorial on how to validate SWIFT and BIC Codes in PHP, and for a detailed explanation of what components the code consists of I suggest your read the intro section of that tutorial first.
Click here to read on.
Posted by Garren Harland on July 6, 2009, 6:40 pm.
BIC and SWIFT codes have a pretty simple format, and are therefore not that difficult to validate with PHP using regular expressions. Indeed, before we look into the regular expression itself, let us have a look at the build-up of a SWIFT/BIC Code. We will use the Swiss bank UBS' Code as an example: UBSWCHZH80A.
Click here to read on.
Posted by Garren Harland on July 6, 2009, 4:32 pm.
Here is a function that can be used to validate UK Postcodes using PHP and Regular Expressions. This code is a prime example of Regular Expressions method of validating a string from left to right. For instance, if AA99 is not checked for before AA9, our validation function would simply accept AA9 and would ignore any postcodes containing two numeric values at the end.
Click here to read on.
Posted by Garren Harland on July 6, 2009, 3:51 pm.
Need to validate your website users' UK Postcodes? Here's how it is done using regular expressions in JavaScript. When constructing regular expressions it is always important to remember that they compare strings from left to right. So in this case, we want AA99 to be tested before AA9.
Click here to read on.
Posted by Garren Harland on July 3, 2009, 12:50 pm.
As the title indicates, this tutorial will teach you how to validate a website URL using JavaScript. This method has a few advantages over validating a website URL using PHP, as the validation process takes place within the browser, meaning no server request or reload is necessary.
Click here to read on.
Posted by Garren Harland on July 2, 2009, 11:43 pm.
As the title indicates, this tutorial will teach you how to validate an email address using JavaScript. This method has a few advantages over validating an email address using PHP, as the validation process takes place within the browser, meaning no server request or reload is necessary.
Click here to read on.
Posted by Garren Harland on June 29, 2009, 10:42 am.
A regular expression is a search a search pattern, that analyzes a string from left to right. Most symbols within a regular expression merely represent themselves, but there are a few that have specific meanings and cause the search pattern to act in a certain way.
Click here to read on.
Posted by Garren Harland on June 26, 2009, 7:30 pm.
Do you need to validate user emails for your website? No problem. Here's how it is done using regular expressions.
Click here to read on.
myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com