ARCHIVE / What are regular expressions?

Regular expressions are a means of parsing or dissecting strings of text by using another string of text that defines a set of syntactic rules.  For example, if we had a list of deserts such as the one below:

apple strudel
chocolate éclair
gingerbread cookie
strawberry shortcake
chocolate chip cookie 

We could use a regular expression such as /^chocolate/ to select only the lines beginning with the string "chocolate" or /^chocolate.+cookie$/ to select only the lines that begin with "chocolate" and end with "cookie".  Since different types of regular expressions are supported by different regular expression parsers, our example will only work with those parsers that interpret the search string as intended.  Regular expression parsers are built into many programming languages, such as Perl, PHP and JavaScript, as well as some shells, utility programs and a number of databases.

last updated 2007.09.25

RELATED PAGES

What is Perl best suited for? What is Perl?

RELATED TOPICS

 

Terms of Use · Privacy Policy ©2017