Programmer's Guide to Regular Expressions
Credits: This tutorial is written by David Andersson (Liorean). Please see footnote for more information on author.
What is a regular expression?
Regular expressions is a form of pattern matching that you can apply on textual content. Take for example the DOS wildcards ? and * which you can use when you're searching for a file. That is a kind of very limited subset of RegExp. For instance, if you want to find all files beginning with "fn", followed by 1 to 4 random characters, and ending with "ht.txt", you can't do that with the usual DOS wildcards. RegExp, on the other hand, could handle that and much more complicated patterns.
Regular expressions are, in short, a way to effectively handle data, search and replace strings, and provide extended string handling. Often a regular expression can in itself provide string handling that other functionalities such as the built-in string methods and properties can only do if you use them in a complicated function or loop.
other languages such as PHP or VBScript use other delimiters, in
/) when you declare RegExp
|RegExp Object Constructor|
||The global search flag makes the RegExp search for a pattern throughout the string, creating an array of all occurrences it can find matching the given pattern.|
||The ignore case flag makes a regular expression case insensitive. For international coders, note that this might not work on extended characters.|
||This flag makes the beginning of input (