in reply to Meaning of the regex?? Help!!
Allow me to introduce you to a handy CPAN module that I discovered by way of another kind monk some time ago (paying it forward if you will, even though I no longer recall who pointed me in this direction)
YAPE::Regex::Explain -- an handy tool for explaining regular expressions. I use it frequently when I come across a regex that I don't understand. Here's a quick example based on your request:
#!/usr/bin/perl -wl use YAPE::Regex::Explain; my $regex = qr/[a-zA-Z][a-zA-Z][a-zA-Z]\d\d,\s+\interlock/; print YAPE::Regex::Explain->new($regex)->explain;
You will see the \interlock yeilds an "Unrecognized escape '\i' passed through" --- which YAPE ignores.
moritz pointed this out above.
YAPE will produce the following output. (Notice that the '\i' has been removed from the regex.
The regular expression: (?-imsx:[a-zA-Z][a-zA-Z][a-zA-Z]\d\d,\s+interlock) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- [a-zA-Z] any character of: 'a' to 'z', 'A' to 'Z' ---------------------------------------------------------------------- [a-zA-Z] any character of: 'a' to 'z', 'A' to 'Z' ---------------------------------------------------------------------- [a-zA-Z] any character of: 'a' to 'z', 'A' to 'Z' ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- , ',' ---------------------------------------------------------------------- \s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- interlock 'interlock' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
|
|---|