Regular expressions, the source of the letters “re” in “grep,” are the foundation for creating a powerful and flexible text-processing tool. Expressions can add, delete, segregate, and generally manipulate all kinds of text and data. They are simple statements that enhance a user’s ability to process files, especially when combined with other commands. If applied properly, regular expressions can significantly simplify a tall task.
Many different commands in the Unix/Linux world use some form of regular expressions in addition to some programming languages. For instance, the sed and awk commands use regular expressions not only to find information, but also to manipulate it.
There are actually many different varieties of regular expressions. For instance, Java and Perl both have their own syntax for regular expressions. Some applications have their own versions of regular expressions, such as Sendmail and Oracle. GNU grep uses the GNU version of regular expressions, which is very similar (but not identical) to POSIX regular expressions.
In fact, most of the varieties of regular expressions are very similar, but they do have key differences. For instance, some of the escapes, metacharacters, or special operators will behave differently depending on which type of regular expressions you are using. The subtle differences between the varieties can lead to drastically different results when using the same expression under different regular expression ...