Just what exactly are regular expressions and what are they used for.
This first tutorial on regular expressions shows you how to define a regular expression and how to use it to test if a text field contains a specified pattern.
Ignore Case and Global
This tutorial on regular expressions shows you how to retrieve all copies of a pattern into an array by using "global" and also how to ignore capitalization when locating the matches to your pattern.
Regular Expressions can be used with the replace method associated with string objects to find and replace text.
You can use regular expressions with the string object's split method to control how a string is split up into array elements.
Start and End
Having learned the main ways of using regular expressions we now move on to start looking at what can be included in the regular expression itself. We begin by looking at the characters that match the start and end of text.
The characters that have a special meaning in regular expressions are called "meta characters". Here we look at what all of these characters are and how we can get their normal meanings when we want to include the characters as their normal values.
You can group characters together in a regular expression allowing a match on any one.
Often you want to match a pattern where one or more characters is repeated. Here is how to define the number of repetitions of a character that you want to test for.
Greedy, Reluctant, and Possessive
When you start specifying a variable length pattern to match against then it becomes possible sometimes to match that pattern against shorter or longer sections of the text. Here's how to tell it whether to match the longest or shortest possible section of text.
Some character classes are so commonly referenced that they have their own one or two character abbreviation defined.
Some special characters that are not able to be entered directly have their own special escape codes that you can use for them in regular expressions.
ASCII and Unicode
When you want to put any character at all into your regular expression and it is not available directly from the keyboard and doesn't have its own special escape code then you can use the appropriate ASCII or unicode escape code to specify it.
As well as having escape characters allowing you to test for the start and end of the string, regular expressions also have escape characters that allow you to test for word and non-word boundaries.
Regular Expressions are at their most useful when you use groups. The simplest use for groups is to allow you to test for multiple repetitions of a group of characters rather than just an individual character.
Any groups that you define within your regular expression will save the matching text to the backreference array allowing you to refer to that exact text in your processing.
There are a number of different reasons for using groups. Where you need a group that you don't want backreferenced you can define the group as non-capturing.
Regular Expressions do not normally treat new lines as a special boundary condition. By setting multiline mode you can test for new line boundaries more easily.
The RegExp Object
properties of RegExp
There are quite a few properties belonging to the RegExp object. Some we have met before.
More Properties of RegExp
There are also a number of properties that RegExp has available to us that we haven't looked at before.
All of the methods that you can use with regular expression objects.
A list of all of the methods you can use with string objects that use regular expressions.
A summary of all of the different regular expression patterns and what they mean complete with links back to the tutorials that provide additional information about the specific patterns.