Re: how to get references from imbricated capturing parenthesis ?
- From: rvtol+news@xxxxxxxxxxxx (Dr.Ruud)
- Date: Sat, 30 Jun 2007 03:00:11 +0200
marin schreef:
I'm trying to get references from a simple regular
exepression like this :
"a40d7412" =~ /(([[:xdigit:]]{2})*)/;
print "$1: <$2><$3><$4><$5>\n";
This prints :
a40d7412: <12><><><>
How to get all references
Verbose variant:
#!/usr/bin/perl
use strict;
use warnings;
my $s = 'a40d7412';
my ($m, @m) = $s =~
/(
[[:xdigit:]] {2} # 2 hex-digits
)/xg; # each
print "$m: <",
join('><', @m),
">\n";
__END__
Terse variant:
@m = $s =~ /../g; # no capturing () needed
{ local $" = '><'; # see perlvar
print shift(@m), ": <@m>\n";
}
See also `perldoc -f pack` (the H-template).
and not the last one in the second
parenthesis pair ?
You shouldn't suggest the wrong approach as part of the solution.
:)
--
Affijn, Ruud
"Gewoon is een tijger."
.
- References:
- Prev by Date: Re: Adding a line in a file inside many directories
- Next by Date: Re: Net::SFTP functions
- Previous by thread: Re: how to get references from imbricated capturing parenthesis ?
- Index(es):