| author | Christian Urban <urbanc@in.tum.de> |
| Tue, 09 May 2017 12:31:55 +0100 | |
| changeset 490 | 8a07f7256f2a |
| parent 474 | 331b2c9e525f |
| child 558 | c9da2c4586f2 |
| permissions | -rw-r--r-- |
# example provided by Daniel Baldwin nums = (1..1000) #iterate through the nums 1-1000 nums.each do |i| start_time = Time.now string = "a" * i #create a new regular expression based on current value of i re_str = "a?" * i + "+" + "a" * i re = Regexp.new(re_str) re.match(string) #if re.match(string) # puts "matched string a * #{i} with regex #{re}" #else # puts "unmatched string a * #{i} with regex #{re}" #end puts "#{i} %.5f" % (Time.now - start_time) end