|
|
| Using Regular Expressions |
|
|
| Pattern Matching |
Table | Description of Special Characters in Regular Expressions | ||
|
|
|
|
| To… | Use… | Example |
|
|
|
|
| Match the end of a | match_expression$ | To match all |
| line |
| occurrences of stack |
|
|
| that occur at the end of |
|
|
| a line, enter: |
|
|
| stack$ |
|
|
|
|
| Match entire lines | ^match_expression | The following regular |
|
| $ | expression would match |
|
|
| all occurrences of |
|
|
| stack_push as long as |
|
|
| it appeared on a line by |
|
|
| itself: |
|
|
| ^stack_push$ |
|
|
|
|
| Repeat a single | single_character* | To match ab, followed |
| character |
| by any number of c's, |
|
|
| followed by a d (for |
|
|
| example, abcd, abccd, |
|
|
| and abcccd), enter: |
|
|
| abc*d |
|
|
| Also note that "any |
|
|
| number of" includes |
|
|
| zero occurrences of a |
|
|
| character. Therefore, |
|
|
| the string "abd" would |
|
|
| also match. |
|
|
|
|
| Repeat a | [match_string]* | To match ab, followed |
| [match_string] |
| by any sequence of |
|
|
| digits, followed by c, |
|
|
| enter: |
|
|
| |
|
|
|
|
Appendix C | 359 |