System Tools

Regular Expressions / REGEX

What is the purpose of Regular Expressions aka REGEX ?


Regular Expressions, generally called REGEX are primarily used to perform advanced operations on textual data. Overall, it's a set of rules that will be applied to a small text in order to format or validate its structure. This is particularly useful in the web page creation process or to check data in an HTML form for example.
Indeed, when you publish a form on Internet to collect data, you must ensure that  all information are correct : email address format, web site URL, birth date, complexity of a password and so on.
From a security point of view, the right use of REGEX is critical : Controlling and filtering data entered by visitors avoid or mitigate the risk for your web site to be hacked. As most attacks are based on SQL injection, code inclusion or malformed content, not checking data entered though a form is extremely dangerous.
If you want to program it by yourself it will take time and energy. REGEX may help you to do it easily, even if you need to firstly understand how it works.
Click here to get details about REGEX on Wikipedia

As regular expressions syntax and use are not so easy to understand if you're not dealing with that on a daily basis, you may find the following tool very useful : Expresso.

Expresso 3.0 Brief Description 


expresso
Expresso 3.0
This application exclusively focuses on REGEX rules automatic generation. There is a lot of templates or pre-defined set of rules that works out of the box.  You can use those templates, customize them to fit your needs and test them inside the software with sample data. 
Regex engine of Expresso is very powerful. You'll just have to select the right options in different tabs and Expresso will "build" the requested regular expression for you.
Simply copy and paste the result in your code.

About the licence : Product download is free ! After 60 days you must register (for free) this software if you intends to continue using the application. My advice is to immediately register your licence as it's completely free.

Main options of Expresso 3.0


Here are some screenshots from the three main tabs of Expresso 3.0 : 
- Regular Expressions testing
- Regular Expression rules
- Library of pre-defined REGEX templates you can customize in the second tab.

 

Design rules options for Expresso 3.0


Just to give you an idea on on how you can finely customize the rules you can have a look on the following screenshots. 

 

Some Regular Expressions examples 


In order to illustrate the REGEX concept, here are some common examples you may find useful to validate standard information.

Email address

([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})
 

Web site URL

(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/?[\w\.?=%&=\-@/$,]*
 

IP Address

(?<First>2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?<Second>2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?<Third>2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?<Fourth>2[0-4]\d|25[0-5]|[01]?\d\d?)
 

Credit Card number

^
(?:(?<Mastercard>5[1-5]\d{14})|
(?<Visa>4(?:\d{15}|\d{12}))|
(?<Amex>3[47]\d{13})|
(?<DinersClub>3(?:0[0-5]|6[0-9]|8[0-9])\d{11})|
(?<Discover>6011\d{12}))
\s*$


Expresso 3.0 Download


 
Version :  3.0 (.NET Framework needed)
Licence :  Freeware
Author :  Ultrapico
 

You have no rights to post comments

Select your language :

Newsletter

Contact

Related articles