Here are two pattern matches:
First guess what they store in the $DIGIT variables. Then run them and examine the results. Do you know why the capture-variables hold the strings they do? I'll post the answer later. (I'm currently in the middle of my fraternity's Initiation Week, and am busy running events.)"a" =~ /((a)*)*/ and printf("1:%s, 2:%s\n", defined($1) ? "'$1'" : "undef", defined($2) ? "'$2'" : "undef", ); "ab" =~ /((a)|(b))*/ and printf("1:%s, 2:%s, 3:%s\n", defined($1) ? "'$1'" : "undef", defined($2) ? "'$2'" : "undef", defined($3) ? "'$3'" : "undef", );
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Interesting Regex Behavior
by tye (Sage) on Nov 22, 2002 at 16:52 UTC | |
|
Re: Interesting Regex Behavior
by broquaint (Abbot) on Nov 22, 2002 at 15:26 UTC | |
by japhy (Canon) on Nov 22, 2002 at 15:43 UTC | |
|
Re: Interesting Regex Behavior
by BrowserUk (Patriarch) on Nov 22, 2002 at 16:49 UTC | |
|
Re: Interesting Regex Behavior
by dws (Chancellor) on Nov 23, 2002 at 04:30 UTC |