# HG changeset patch # User Christian Urban # Date 1352147278 0 # Node ID 0c96b2c04591993ea529626c62448062dc0b646a # Parent f28824933a663e3f4044c654151880795200b2db added ruby version diff -r f28824933a66 -r 0c96b2c04591 re-internal.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/re-internal.rb Mon Nov 05 20:27:58 2012 +0000 @@ -0,0 +1,19 @@ +nums = (1..100) + +#iterate through the nums 1-100 +nums.each do |i| + + start_time = Time.now + string = "a" * i + + #create a new regular expression based on current value of i + re = Regexp.new(/((a?){#{i}})(a{#{i}})/) + + if re.match(string) + puts "matched string a * #{i} with regex #{re}" + else + puts "unmatched string a * #{i} with regex #{re}" + end + + puts "in = #{(Time.now - start_time) * 1000} milliseconds" +end