A Little about the Regular Expressions
A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as *.txt to find all text files in a file manager. The regex equivalent is .*\.txt$.
But you can do much more with regular expressions. In a text editor like EditPad Pro or a specialized text processing tool like PowerGREP, you could use the regular expression \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b Analyze this regular expression with RegexBuddy to search for an email address. Any email address, to be exact. A very similar regular expression (replace the first \b with ^ and the last one with $) can be used by a programmer to check if the user entered a properly formatted email address. In just one line of code, whether that code is written in Perl, PHP, Java, a .NET language or a multitude of other languages.
If you are not a programmer, you use regular expressions in many situations just as well. They will make finding information a lot easier. You can use them in powerful search and replace operations to quickly make changes across large numbers of files. A simple example is gr[ae]y which will find both spellings of the word grey in one operation, instead of two. There are many text editors and search and replace tools with decent regex support.
If you’re hungry for more information on regular expressions after reading this website, there are a variety of books on the subject.
RegExLib.com, the Internet’s first Regular Expression Library. They have indexed 1935 expressions from 1188 contributors around the world.
A large number of tools incorporate regular expressions as part of their functionality. Unix-oriented command line tools like grep, sed, and awk are mostly wrapper for regular expression processing. Many text editors allow search and/or replacement based on regular expressions. Many programming languages, especially scripting languages such as Perl, Python, and TCL, build regular expressions into the heart of the language. Even most command-line shells, such as Bash or the Windows-console allow restricted regular expressions as part of their command syntax.
There are a few variations in regular expression syntax between different tools that use them. Some tools add enhanced capabilities that are not available everywhere. In general, for the simplest cases, this tutorial will use examples based around grep or sed. For a few more exotic capabilities, Perl or Python examples will be chosen. For the most part, examples will work anywhere; but check the documentation on your own tool for syntax variations and capabilities.
A good tutorial on Regular expressions can be found on http://gnosis.cx/publish/programming/regular_expressions.html
The tutorial has been written by David Mertz (mertz@gnosis.cx)
A good amount of information and other tutorails on Regular Expressions can be found on
regular-expressions.info (Recommended to visit, if you would like to have more information on Regular expressions).
And RegExLib.com, the Internet’s first Regular Expression Library. A great Thanks to all the contributors, who have contributed to the library and helping all the people like us.