[Chicago-talk] \1 vs $1
Andy_Bach at wiwb.uscourts.gov
Andy_Bach at wiwb.uscourts.gov
Wed Nov 3 12:42:34 CST 2004
I just read a post:
> ... and \1 is deprecated for $1.
and having stumbled over this recently, I was a little suprised to hear of
the deprecation. What I'd found was \1 isn't the same as $1, in that
s/(.)\1//;
deletes duplicate chars, while;
s/(.)$1//;
depends upon the value of $1 - which, in this case'd be set *before* the
subst got invoked! On the right hand side, $1 is what we expect but \1
also can change during the course of a regex evaluation - as the
parser/matcher works, \1 will take on different values during backtracking
etc - though, in the end \1 is the same as $1.
Er, am I all wet here?
a
Andy Bach, Sys. Mangler
Internet: andy_bach at wiwb.uscourts.gov
VOICE: (608) 261-5738 FAX 264-5932
"If there be time to expose through discussion the falsehood and
fallacies, to avert the evil
by the process of education, the remedy to be applied is more speech, not
enforced silence."
Justice Louis Brandeis
More information about the Chicago-talk
mailing list