author | Christian Urban <urbanc@in.tum.de> |
Mon, 05 Nov 2012 20:31:58 +0000 | |
changeset 58 | f516892da470 |
parent 57 | 0c96b2c04591 |
child 60 | 68d664c204d2 |
permissions | -rw-r--r-- |
58 | 1 |
# provided by Daniel Baldwin |
2 |
||
57 | 3 |
nums = (1..100) |
4 |
||
5 |
#iterate through the nums 1-100 |
|
6 |
nums.each do |i| |
|
7 |
||
8 |
start_time = Time.now |
|
9 |
string = "a" * i |
|
10 |
||
11 |
#create a new regular expression based on current value of i |
|
12 |
re = Regexp.new(/((a?){#{i}})(a{#{i}})/) |
|
13 |
||
14 |
if re.match(string) |
|
15 |
puts "matched string a * #{i} with regex #{re}" |
|
16 |
else |
|
17 |
puts "unmatched string a * #{i} with regex #{re}" |
|
18 |
end |
|
19 |
||
20 |
puts "in = #{(Time.now - start_time) * 1000} milliseconds" |
|
21 |
end |