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
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
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
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
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//
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
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
Wizard
can add features to the engine at a whim
has pumpking status
japhy
--
Perl and Regex Hacker
In reply to
7 Stages of Regex Users
by
japhy
Title:
Use:
<p> text here (a
p
aragraph) </p>
and:
<code> code here </code>
to format your post, it's "
PerlMonks-approved HTML
":
Posts are HTML formatted.
Put
<p> </p>
tags around your paragraphs. Put
<code> </code>
tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read
Where should I post X?
if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
How do I compose an effective node title?
How do I post a question effectively?
Markup in the Monastery
Posts may use any of the
Perl Monks Approved HTML tags
:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
For:
Use:
&
&
<
<
>
>
[
[
]
]
Link using PerlMonks shortcuts!
What shortcuts can I use for linking?
See
Writeup Formatting Tips
and other pages linked from there for more info.