Re: regex capture \1 versus $1
- --- In firstname.lastname@example.org, Jeff 'japhy' Pinyan <japhy@p...>
> On Aug 1, acummingsus said:[ why the error ]
> It's not an error, it's a warning.regex, but
> > \1 better written as $1 at /home/al/bin/wthr_pbml line 9.
> > \2 better written as $2 at /home/al/bin/wthr_pbml line 9.
> Because Perl prefers you use $<DIGIT> outside of the *actual* regular
> expression. The right-hand side of an s/// is not parsed as a
> as a double-quoted string. You should use *variables* there, not the\1 is a part of a capturing group. And, capture group is part of the
> regex escape sequence denoting a capturing group.
m for match a.k.a "regex" a.k.a. m/(.)\1/; a.k.a. s/(.)\1//;
The right hand portion of a substitution, however, is *not* defined as
"regex". And, said right hand portion differs from the left hand
portion in that the left hand portion *is* "regex".
So, now I know what I didn't know back then which is that
*I_formerly_did_not_know* that the right hand portion of a
substitution is *not* "regex".
So, as a beginner, I *formerly* didn't have/own sufficient definition
and/or context of what "regex" is when, on not this but a different
beginner group, I was told "\1 must be used within the regex itself".
Super! Thank you! And, HTH someone, some how, in some way.