ISAI student has asked for the wisdom of the Perl Monks concerning the following question:
Hello all. In Ruby & Python, one can have a regular expression, with backreferences, and then access the backrefernces as a list, and it's sub lists. For example, The Ruby code below returns the 1st backreference from a regexp
return line.match(/^integer.*?\"(\S+)\"/)[1]
I am looking for something other than: @a =($1,$2,$3,$4) ; And rather:
I could not find something similar to that in PERL, other than a reference to $+ $-, which is not what I wanted and has a warning about performance. Any ideas?@a=$foo[1..4];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A list of backreferences from a regex
by Corion (Patriarch) on Mar 27, 2013 at 08:42 UTC | |
|
Re: A list of backreferences from a regex
by dave_the_m (Monsignor) on Mar 27, 2013 at 10:12 UTC | |
|
Re: A list of backreferences from a regex
by hdb (Monsignor) on Mar 27, 2013 at 08:48 UTC |