Direi:
ma anche:
Cito:
str.gsub(pattern, replacement) => new_str
If a string is used as the replacement, special variables from the
match (such as $& and $1) cannot be substituted into it, as
substitution into the string occurs before the pattern match starts.
However, the sequences \1, \2, and so on may be used to interpolate
successive groups in the match.
comunque quegli \1, \2, … fanno molto Perl … 
Un altro modo (+ o - dal libro di Matz: the ruby programming language) :
a = “ciao, oggi il 2008/10/17 (venerdi 17!)”
pattern = /([0-9]{4})/([0-9]{2})/([0-9]{2})/
pattern =~ a #pattern matching here
Ora, possiamo recuperare l’ultimo match con last_match:
data = Regexp.last_match
p data
#<MatchData “2008/10/17” 1:“2008” 2:“10” 3:“17”>
In pratica l’oggetto contiene l’ultimo match, se abbiamo creato delle
subexpressions tra parantesi, l’oggetto MatchData contiene ogni
subexpression.
p data.captures
[“2008”, “10”, “17”]
METODI di LAST MATCH:
p data.methods - Object.methods # questo trucchetto mi piace un
sacco! restituisce i metodi specifici di data…
[“string”, “end”, “values_at”, “captures”, “size”, “pre_match”,
“offset”, “post_match”, “select”, “length”, “begin”, “[]”]
… scusate il delirio , un altro caffe e mi sveglio …
tuk
Il giorno 18/ott/08, alle ore 18:51, Massimo A. ha scritto: