# Introduction to Regular Expressions

A Regular Expression is a way of describing a pattern of text.

Unless you have worked with regular expressions before, the term and the concept may be unfamiliar to you. However, they may not be as unfamiliar as you think.

Think about how we search for files on your hard disk. One way is to specify the name of a file completely, for example:

- data1.dat, data2.dat, data_old.dat, dataCurrent.dat

This allows us to find where on the disk a particular file is. Using the * character allows us to search for many files at once. For example, 'data*.dat' matches all of the following:

- data.dat, data1.dat, data2.dat, data12.dat, datax.dat, dataXYZ.dat

If we know that we are looking for a ".dat" file, but cannot remember its name, we might try "*.dat", which would find all of the above file names, and any other file that ended with ".dat".

While this method of searching for files can certainly be useful, it is also very limited. The limited ability of the ? and * wildcard characters give you an idea of what regular expressions can do, but regular expressions are much more powerful and flexible.

Some example regular expressions:

Regular Expression | Meaning
--- | ---
match(#myField, "\d{5}(-\d{4})?") | Returns TRUE if the contents of myField are a 5 digit or 9 digit US Zip Code
snip(#myField, "(?i:<[a-z]+[^>]*>)|(</[a-z\\d]+>)") | Find any UPPER or lower case HTML tag and remove it from myField
replace("John Smith", "(\w+) (\w+)", "$2 $1") | Reverses the order of the two words in the string, what ever the words are - in this example, produces "Smith John"

For more information about regular expressions, see:

Regular Expression Syntax

Using Regular Expressions

Regular Expression Examples

Also, see the tutorial: Splitting the Name Field for a detailed discussion of how to take input like "Mr John Smith" and split it into First Name, Last Name, Dear, and Contact using regular expressions.