From: Bertram Scharpf on 19 Dec 2009 09:13 Hi, Am Freitag, 18. Dez 2009, 23:39:40 +0900 schrieb Robert Klemme: > 2009/12/18 beny 18241 <beny18241(a)gmail.com>: > > ok closed Ifigue it out :) > > > > puts ARGF.read.scan(/<mms:MmsCcppAccept>.*?<\/mms:MmsCcppAccept>/m) > > Eric's solution is better for large files because it requires reading > the file line by line only. Note that it uses a special feature of > "if" when using a range with boolean expressions: in that case > matching state is stored and the complete expression is true when the > first matches, stays true and only switches back to false if the > second matches: > > 10.times {|i| if /^3/ =~ i.to_s .. /^7/ =~ i.to_s; puts i; end} The name of the feature is flip-flop if you like to google for it. I'm not sure whether it really makes code more readable. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany * Discover String#notempty? at <http://raa.ruby-lang.org/project/step>.
First
|
Prev
|
Pages: 1 2 Prev: problem requiring gems under 1.9.1 mingw Next: ruby in twenty minutes not work |