Pattern Matching
A pattern describes text in a general way. Searching based on literal text yields only one match, whereas searching with a pattern can match a whole class of text that shares the specified characteristics. Phone numbers (in North America) are a perfect example: three groups of digits separated by various punctuation characters. Here's a simple Text Machine pattern that will find most phone numbers:
[3 digits, punctuation, 3 digits, punctuation, 4 digits]
Let's suppose that you have a list of addresses phone numbers gathered from different sources. The phone numbers are likely to be in many formats: some with / and -, some with periods, etc. To convert them to a consistent format you need to keep the three groups of digits and insert new punctuation in between. With TextPipe's EasyPatterns, this is as easy as
Search for: "[punctuation capture(3 digits) punctuation capture(3 digits) punctuation capture(4 digits)]"
Replace with: "$1-$2-$3"
This section introduces all of the essential elements of EasyPattern patterns. If you are new to pattern-matching, there's no reason you have to read the entire section at once. Feel free to stop after any section and continue with the next 2 sections or spend time reviewing example. Also, don't worry if you don't immediately understand every point. The only way to learn pattern matching is to create your own patterns, including the inevitable trial and error required to get just the right match. TextPipe's trial run area was designed with this in mind.
Throughout this text and the reference section, double quotes are used around both the pattern and the example text that it would match. The double quotes should *NOT* be entered in TextPipe.
Perl Regular Expressions
This HTML document has been generated automatically from the original man page. If there is any nonsense in it, please consult the man page, in case the conversion went wrong.
- PCRE REGULAR EXPRESSION DETAILS
- BACKSLASH
- CIRCUMFLEX AND DOLLAR
- FULL STOP (PERIOD, DOT)
- MATCHING A SINGLE BYTE
- SQUARE BRACKETS
- POSIX CHARACTER CLASSES
- VERTICAL BAR
- INTERNAL OPTION SETTING
- SUBPATTERNS
- NAMED SUBPATTERNS
- REPETITION
- ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS
- BACK REFERENCES
- ASSERTIONS
- CONDITIONAL SUBPATTERNS
- COMMENTS
- RECURSIVE PATTERNS
- SUBPATTERNS AS SUBROUTINES
- CALLOUTS
- UTF-8 Support
- Differences from Perl
|