O
OwlHoot
To repeat the title, in case it is munged by Google Groups:
if ('A:B:C' =~ /.*?)$/) then why the heck is $1 'B:C' and not just
'C'
I've been developing with perl for years; but even simple things in it
still
sometimes throw up surprises.
The regexp /.*?)$/ is anchored on the right by $, then comes a non-
greedy
match which, AIUI, is the "shortest string it can get away with",
preceded
by a colon. So I would expect this to pick up just the "C", as it does
with
/([^:]*)$/.
Am I assuming/doing something silly? It is friday afternoon after all.
Cheers
John R Ramsden
if ('A:B:C' =~ /.*?)$/) then why the heck is $1 'B:C' and not just
'C'
I've been developing with perl for years; but even simple things in it
still
sometimes throw up surprises.
The regexp /.*?)$/ is anchored on the right by $, then comes a non-
greedy
match which, AIUI, is the "shortest string it can get away with",
preceded
by a colon. So I would expect this to pick up just the "C", as it does
with
/([^:]*)$/.
Am I assuming/doing something silly? It is friday afternoon after all.
Cheers
John R Ramsden