On 3/7/07, Jennifer Foo <[EMAIL PROTECTED]> wrote:
Someone posted this regex question which I can't understand for.
perl -e '$_=abc.eeeee.i;
s/(\.\w+)?$/.out/;
print;'
the result is: abceeeeei.out
Why is this?Please help explain it.Thanks!
I think you will be less confused if you change the code to
perl -e '$_="abc.eeeee.i";
s/(\.\w+)?$/.out/;
print;'
abc.eeeee.i is actually 'abc' . 'eeeee' . 'i' or 'abceeeeei'. You
might want to look up Perl's behaviour with respect to barewords.
That said the regex replaces either a period followed by one or more
word characters (A-Z, a-z, 0-9, and _) at the end of the string or
nothing at the end of a string with ".out".
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/