There is no use collecting information that is clearly incorrect. Unless you're a corporate site administrator, there will probably be a limit to the amount of information you can hold in a database, and therefore it makes no sense to fill the database with incorrect information. Something is needed to ensure that users entering data into your forms are entering data that you can use and that meets your expectations of the data.
Regular Expressions can be used as a way of matching patterns in strings. By patterns, I mean specific occurrences of letters, numbers or punctuation marks. This is an extremely effective way of checking that the information visitors to your site have entered into your forms is correct. When I say correct I mean generally in the correct format; if a user spells their name incorrectly when entering their email address, there's not a lot you can do. But if they enter it and fail for some reason to include the @ character, for example, this at least can be detected. There is a home for regular expressions in any form, and almost any field that requires character input can be checked.
You define a regular expression that matches correctly entered data and then passes the form to the relevant CGI app, or you can define regular expressions that match incorrectly entered data and output an error message if this data is entered. A combination of these two approaches will ensure that you are given data in a format that you are able to work with.
Comments
Be the first to write a comment
You must me logged in to write a comment.