re-internal.rb
changeset 57 0c96b2c04591
child 58 f516892da470
equal deleted inserted replaced
56:f28824933a66 57:0c96b2c04591
       
     1 nums = (1..100)
       
     2 
       
     3 #iterate through the nums 1-100
       
     4 nums.each do |i|
       
     5 
       
     6 	start_time = Time.now
       
     7 	string = "a" * i
       
     8 
       
     9 	#create a new regular expression based on current value of i
       
    10 	re = Regexp.new(/((a?){#{i}})(a{#{i}})/)
       
    11 
       
    12 	if re.match(string)
       
    13 		puts "matched string  a * #{i} with regex #{re}"
       
    14 	else
       
    15 		puts "unmatched string a * #{i} with regex #{re}"
       
    16 	end
       
    17 	
       
    18 	puts "in = #{(Time.now - start_time) * 1000} milliseconds"
       
    19 end