Next | Regular Expression Mastery | 63 |
/^(\w+|::)*$/
Matches Perl identifiers like Foo and Getopt::Std.
What does it do with abcd! ?
\w+ <a b c d> ! No good \w+ \w+ <a b c><d> ! Also no good \w+ \w+ <a b><c d> ! Also no good \w+ \w+ \w+ <a b><c><d> ! Still no good \w+ \w+ <a><b c d> ! Also no good \w+ \w+ \w+ <a><b c><d> ! Still no good \w+ \w+ \w+ <a><b><c d> ! Still no good \w+ \w+ \w+ \w+ <a><b><c><d> ! Guess what? Gives up.
This doesn't include all the times it tried to match :: against one of the letters, or the times it tried making * match no times, or...
Next | Copyright © 2002 M. J. Dominus |