Advertisement

Tutorials

Home Tutorials Beginner Tutorial

Perl Regular Expression Tutorial

Page Visited Visited: 10460
3.0/5.0 (5 votes total)
Rate:

by Carl Franklin and Gary Wisniewski
June 16, 2006


Carl Franklin and Gary Wisniewski
Carl Franklin and Gary Wisniewski has written 1 tutorials for CGIDir.
View all tutorials by Carl Franklin and Gary Wisniewski...

Overview

A regular expression is a string of characters which tells the searcher which string (or strings) you are looking for. The following explains the format of regular expressions in detail. If you are familiar with Perl, you already know the syntax. If you are familiar with Unix, you should know that there are subtle differences between Perl's regular expressions and Unix' regular expressions.


Simple Regular Expressions


In its simplest form, a regular expression is just a word or phrase to search for. For example,

  gauss

would match any subject with the string "gauss" in it, or which mentioned the word "gauss" in the subject line. Thus, subjects with "gauss", "gaussian" or "degauss" would all be matched, as would a subject containing the phrases "de-gauss the monitor" or "gaussian elimination." Here are some more examples:

  carbon

    Finds any subject with the string "carbon" in its name, or which mentions carbon (or carbonization or hydrocarbons or carbon-based life forms) in the subject line.

  hydro

    Finds any subject with the string "hydro" in its name or contents. Subjects with "hydro", "hydrogen" or "hydrodynamics" are found, as well as subjects containing the words "hydroplane" or "hydroelectric".

  oxy

    Finds any subject with the string "oxy" in the subject line. This could be used to find subjects on oxygen, boxy houses or oxymorons.

  top ten

    Note that spaces may be part of the regular expression. The above expression could be used to find top ten lists. (Note that they would also find articles on how to stop tension.)

 

Read on... 


Add commentAdd comment (Comments: 0)  

Advertisement

Related Resources

Other Resources

image arrow