From: Robert Klemme Date: 2008-11-19T16:46:22+09:00 Subject: Re: ruby global regex question. On 19.11.2008 07:08, Einar Magnús Boson wrote: > > That is pretty much how, except globals are hardly thread safe I > think. $1 and the like are robert@fussel ~ $ ruby -e '2.times{|i|Thread.new(i){|ii|4.times{/(\d+)/=~ii.to_s;puts $1;sleep 1}}};sleep 5' 0 1 1 0 1 0 1 0 robert@fussel ~ $ > Use scan instead of gsub: Right, as far as I can see no replacements should be done. Just read only access. html_source.scan %r{(.*?)
}i do table_souce = $1 index_number = table_source[%r{Index\s+(\d+)}, 1].to_i table_source.scan %r{(.*?)}i do do_something_with $1, index_number end end But a proper HTML parser is probably much better. :-) Kind regards robert