Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

7 Stages of Regex Users

by japhy (Canon)
on Nov 18, 2000 at 09:57 UTC ( #42330=perlmeditation: print w/ replies, xml ) Need Help??

As a supplement to the "7 Stages of a Perl Programmer", I present the 7 Stages of Regex Users (as pertains to Perl's special flavor of regexes):

7 Stages of a Regex User

  1. Novice
    • thinks regular expressions are line noise
    • falls prey to "m/usr/bin/" (embedded /'s in m//)
    • has no idea what tr/// is
    • doesn't know about the i modifier
    • gratuitous use of $`, $&, and $'
    • doesn't use \w, \d, \s, etc. metaclasses
    • painfully misuses * and .*
    • puts words in character classes

  2. Initiate
    • still a victim of leaning toothpick syndrome (LTS)
    • uses regexes where chop() or substr() or index() would do
    • tries to use tr/// like s///
    • uses brackets in tr///
    • uses modifiers needlessly (like o, s, and m)
    • does ($x,$y) = ($1,$2), instead of ($x,$y) = /(re)g(ex)/
    • uses | in character classes for alternation
    • uses [^\w] instead of \W
    • tries to delete HTML tags with s/<.*>//g or s/<.*?>//g
    • backslashes needlessly

  3. User
    • uses different m// and s/// delimiters
    • uses regex where index() would do
    • knows about tr///, but uses s/// instead
    • uses regexes in conditionals
    • knows to use the o modifier, but sometimes gets bitten
    • uses backreferences incorrectly sometimes (\1 on the RHS of s///)
    • starts to understand why HTML tags are hard to match with regexes

  4. Adept
    • knows when to use regexes, and when to use string functions
    • knows when to use tr///, and when to use s///
    • leaves the m off // regexes
    • uses the e modifier in s///
    • toys with look-ahead
    • knows to use (?:...) when a backref isn't needed
    • uses precompiled regexes with qr//

  5. Hacker
    • uses look-ahead and look-behind with impunity
    • sighs at the constant-width restraint on look-behind
    • plays with pos() and \G and the g and c modifiers
    • has read "Mastering Regular Expressions"
    • knows how to "unroll the loop"
    • uses re -- and understands the debug output
    • uses closures to make regex matching objects
    • makes nested regexes using (??{...})
    • can read a regex and explain its function

  6. Guru
    • works on the regex engine
    • has patched the engine from time to time
    • uses precompiled regexes as objects
    • refers to "Henry" (that is, Henry Spencer)
    • can explain how any given regex will or won't work

  7. Wizard
    • can add features to the engine at a whim
    • has pumpking status



japhy -- Perl and Regex Hacker

Comment on 7 Stages of Regex Users
Re: 7 Stages of Regex Users
by extremely (Priest) on Nov 18, 2000 at 13:37 UTC
    Stage 4.5:
    • quibbles about "knows to use (?:...) when a (backref|capture) isn't needed"

      --
      $you = new YOU;
      honk() if $you->love(perl)

Re: 7 Stages of Regex Users
by Fastolfe (Vicar) on Nov 19, 2000 at 00:07 UTC
    Stage 8. God

    • can write a regexp that reliably parses HTML tags
    • RSA in 3 lines of perl regex (without using dc)
    • "let there be a regexp engine" and there was a regexp engine
    • doesn't need to know the difference between tr/// and s///
    • can write a regexp that reliably matches events in future human history
(Ovid) Re: 7 Stages of Regex Users
by Ovid (Cardinal) on Nov 19, 2000 at 01:37 UTC
    And let's not forget Stage 0:

    Stage 0. VB Programmer

    • Is amazed at the power of VB's InStr function.
    • Likes to show of his VB "guru" (ack, phht!) status by slipping InStrRev in his programs.
    • Is aware the VB's StrComp can be made case-insensitive, but doesn't understand why this is important.
    (Ovid hopes that no one realizes that he also likes programming in VB.)

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: 7 Stages of Regex Users
by Anonymous Monk on Sep 26, 2007 at 20:17 UTC
Re: 7 Stages of Regex Users
by larsen (Parson) on Sep 27, 2007 at 07:36 UTC
    uses closures to make regex matching objects

    Interesting. Could you digress on that ? Thank you

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://42330]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (15)
As of 2014-07-24 18:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (165 votes), past polls