brwarn has asked for the wisdom of the Perl Monks concerning the following question:
([A-Za-z])\.[A-Za-z],$1
If I replace $1 in regex.txt with \1, I get the error:my $file = "regex.txt"; open FILE, "<", $file or die "Can't open $file: $!\n"; while(my $regex=<FILE>){ my @rex = split(/,/,$regex); chomp($rex[0]); # $rex[0] is set to "([A-Za-z])\.[A-Za-z]" chomp($rex[1]); # $rex[1] is set to "$1" <--not sure how to ge +t ([A-Za-z])group from $rex[0] to be set here. $rrow_test =~ s/$rex[0]/$rex[1]/ig; } # END while(my $regex=<FILE>) close FILE;
Thanks.Reference to nonexistent group in regex; marked by <-- HERE in m/\1 <- +- HERE / at C:\utilities\regexTester.pl line 105, <FILE> line 2.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: backreference replaced as literal or just fails
by GrandFather (Saint) on Mar 10, 2009 at 19:36 UTC | |
by brwarn (Novice) on Mar 10, 2009 at 22:17 UTC | |
|
Re: backreference replaced as literal or just fails
by kennethk (Abbot) on Mar 10, 2009 at 19:04 UTC | |
by brwarn (Novice) on Mar 10, 2009 at 19:32 UTC | |
by kennethk (Abbot) on Mar 10, 2009 at 19:43 UTC | |
by zwon (Abbot) on Mar 10, 2009 at 19:45 UTC |