hi peter!

Peter Bailey [2008-04-09 20:04]:
> Dir.chdir("C:/users/pb4072/documents") do |d| file =
> File.read("test1.txt") output =
> file.gsub(%r{^(<row><entry><text><emph 
> face="b">)(.*)(<\/emph>)}m) do |match| 
> "#{$1}#{$2.gsub(%r{\b\w+\b}){|w|w.capitalize}}#{$3}" end 
> File.open("test1.txt", "w") { |f| f.write output } end
> 
> Here's what I get. It works great, but, I don't understand why
> the $3 text is simply blown away.
because it's reset when you're doing that gsub on $2. the capture
variables only refer to the *last* match. so you have to capture
them into local variables first (can't think of a better way right now).

cheers
jens

-- 
Jens Wille, Dipl.-Bibl. (FH)
prometheus - Das verteilte digitale Bildarchiv für Forschung & Lehre
Kunsthistorisches Institut der Universität zu Köln
Albertus-Magnus-Platz, D-50923 Köln
Tel.: +49 (0)221 470-6668, E-Mail: jens.wille / uni-koeln.de
http://www.prometheus-bildarchiv.de/