in reply to japhy and mystery
Here is my vision. Please entertain it, if you would. If you haven't been able to tell, I'm serious, and I'm a regex fanatic.
Learning Perl's Regular Expressions
japhy -- Perl and Regex Hacker
- Familiarize the reader with the tasks that regular expressions are intended to complete.
- What is a regular expression (regex)?
- What can they do?
- What are some practical uses for them?
- What are some impractical uses for them?
- How can they solve daily programming problems?
- Abstract thinking about regexes.
- How to explain a regex's purpose.
- How to tackle a given parsing problem with a regex.
- How to say what you mean, and mean what you say.
- What else is out there, apart from regexes.
- Simple patterns.
- Plain text: /hello world/
- Safe patterns: /hello \Q$place\E/
- Character classes: /[Hh]ello [Ww]orld/
- Case-insensitivity: /hello world/i
- Alternation: /hello|goodbye/
- Matching something other than $_: $foo =~ /hello/
- More "patterny" patterns.
- Dot: /h.ll/
- Quantifiers: /hello(?: +world)?/
- Macros: /hello\s+world/
- Anchors: /^hello,?\s+world$/
- Alternate m// characters: m!a/b/c!
- Getting something back.
- Capturing: /hello,?\s+(\w+)/
- Back-references: /\b(\w)\w+(\1)\b/
- Global matching: /(\d+)/g
- Regex-y functions: split(), grep(), map()
- Useful variables: $1, @-, @+
- Not-so-useful variables: $`, $&, $'
- More modifiers.
- Modifying .: /a.b/s
- Modifying ^ and $: /^foo$/m
- Explaining your regex using /x
- Using qr// and /o
- Breakpoint: greediness and backtracking
- What is backtracking, and how does it work?
- What is greediness, and how do you avoid it?
- Minimal (lazy) vs. maximal (greedy): /a\w+?z/
- Understanding the "left-most longest" rule.
- Substitution.
- Using s///.
- Calling functions with /e.
- Simple assertions.
- Positive look-ahead: /foo(?=bar)/
- Negative look-ahead: /foo(?!bar)/
- Common traps: "aaabar" =~ /a+(?!bar)/
- More assertions.
- Positive look-behind: /(?<=foo)bar/
- Negative look-behind: /(?<!foo)bar/
- The constant-width assertion plague: /(?<=ab+a)/
- The cut assertion: /(?>a+)a/
- Logic-flow in regexes.
- The conditional assertion: /(?(...)a|b)/
- Embedding code.
- Advanced use of the /e modifier.
- The evaluate assertion: /(?{ code })/
- The delayed regex assertion: /(??{ regex })/
- Advanced global searching.
- The pos() function
- The \G anchor and the /gc modifiers.
- Common mistakes.
- $&, et. al.
- Problems with /$foo/.
- Matching too much.
- Wasteful modifiers.
- Optimizing your regexes.
- "Death to .*."
- Match only what you want.
- Unrolling the loop.
- Concrete applications of regexes.
- Data transformation for sorting.
- Matching in reverse ("sexeger").
- Regex tools and resources.
- Komodo
- YAPE::Regex::Explain
- Regex::Diagram
- GraphViz::Regex_YAPE
- -Dr and -mre=debug
japhy -- Perl and Regex Hacker
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Learning Perl's Regular Expressions
by chromatic (Archbishop) on May 07, 2001 at 09:00 UTC | |
by japhy (Canon) on May 07, 2001 at 17:45 UTC | |
Re: Learning Perl's Regular Expressions
by dws (Chancellor) on May 07, 2001 at 01:48 UTC | |
Re: Learning Perl's Regular Expressions
by sharle (Acolyte) on May 07, 2001 at 04:22 UTC | |
Re: Learning Perl's Regular Expressions
by MeowChow (Vicar) on May 07, 2001 at 23:03 UTC | |
(tye)Re: Learning Perl's Regular Expressions
by tye (Sage) on May 07, 2001 at 20:17 UTC | |
by japhy (Canon) on May 07, 2001 at 20:25 UTC | |
Re: Learning Perl's Regular Expressions
by birdbrane (Chaplain) on May 07, 2001 at 22:46 UTC |
In Section
Meditations