[Image of Linux]
The Personal Web Pages of Chris X. Edwards

Regular Expression Tutorial

--------------------------

WHAT EXACTLY IS A REGULAR EXPRESSION?

Before we look at formal definitions of regular expressions, it is helpful to know that the concept of "strings" is important in defining regular expressions. A "string" is merely as sequence of text characters put together. Imagine a bunch of beads which each have a letter of the alphabet on them. If you put these beads on a physical string, they now have an order and, perhaps, greater meaning. So when the word "string" is used, it is simply an ordered collection of characters. "This" is a string and "that" is another string. "This entire sentence is a string."


"CHRIS" is a string.

Now that we know what a string is, what is the definition of regular expressions? Here's a good official sounding definition from Wikipedia:

Regular expression
A regular expression (abbreviated as regexp or regex) is a string that describes a whole set of strings, according to certain syntax rules. These expressions are used by many text editors and utilities (especially in the Unix operating system) to search bodies of text for certain patterns and, for example, replace the found strings with a certain other string.

Technically, a generalized interpretation of the term "regular expression" could apply to other functions besides the text string processing system. An example would be the very structured and regular syntax used to describe things like programming languages in reference manuals. In this application and others, there is a lot more variability in the specific syntax among various applications. Since pattern matching regular expressions have become somewhat standardized, they are what the term "regular expression" most always refers to.

--------------------------
Previous Home Next
This page was created with only free, open-source, publicly licensed software.
This page was designed to be viewed with any browser on any system.
Chris X. Edwards ~ December 2003