Definitions and uses
Regular expressions enable our program to "search" 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 DNA/protein sequence (the string) contains a motif (the pattern).
- Extract from the string a substring that matches the pattern.
e.g. tell which motif 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.