Substitution, subgroups and numbers
"patrick mezard" <[email protected]> Wed, 18 Dec 2002 17:44:30 GMT
| Newsgroups | gmane.comp.jakarta.oro.user |
|---|---|
| Message-ID | <[email protected]> |
Hello, I'm trying to make a perl substitution using Util.substitute and
Perl5Substitution.
The equivalent perl code is:
**********
use strict;
my $v = "foo1";
$v =~ s/([a-zA-Z]+)(\d+)/${1}2/;
print $v."\n";
**********
which outputs:
>foo2
Using Util.substitute the resulting value is:
>${1}2
Then I tried
$v =~ /([a-bA-Z]+)(\d+)/$1\\2/;
which does not work in perl but works with ORO 2.0.6 (mostly due to
different escaping rules when escaping the rightmost part in ORO).
(Anyway I achieve valid substitutions in other cases, which makes me
think that my code is not the real problem).
I am no perl-expert so maybe this kind of groupid escaping is part of
perl 5.6 regexp. In this case, is there an other way to disambiguate the
right part of the substitution ?
Is this a known limitation/bug/feature to come ?
Thanks for any hint.
Trick
_____________________________________________________________________
GRAND JEU SMS : Pour gagner un NOKIA 7650, envoyez le mot IF au 61321
(prix d'un SMS + 0.35 euro). Un SMS vous dira si vous avez gagné.
Règlement : http://www.ifrance.com/_reloc/sign.sms