Regular Expressions
Definitions and uses
Regular expressions enable our program to "read" text.
Given a string and a
pattern (template), our program
can perform several tasks:
- Determine whether the string contains the pattern, and return
"true" or "false".
e.g. determine whether a sequence (the string) contains some
consensus sequence (the pattern).
- Extract from the string a substring that matches the pattern.
e.g. tell which form of a consensus sequence actually appears in a given
sequence.
- Look for the pattern in the string and replace it with something else.
- Using the split function: look for all appearances of the
pattern in the string and extract the parts
of the string that are not matching the pattern.
In this case, the pattern actually defines the delimiter.
In all these cases we say that the program
matches the pattern against the string.
The patterns themselves are specified using
regular expressions.
Table of Contents.
Next.