re = /^\s{8,9}\d{1,2}\s{2}\|\s{9,10}\d{1,2}\s{2}\|\s{9,10}\d{1,2}$/m
str = ' 12 | 11 | 5
13 | 3 | 13
5 | 16 | 3
15 | 2 | 20
8 | 5 | 16
4 | 12 | 3
20 | 1 | 14
9 | 1 | 1
15 | 13 | 14
15 | 1 | 1
18 | 15 | 5
5 | 1 | 18
13 | 9 | 8
16 | 1 | 1
5 | 5 | 14
7 | 17 | 10
8 | 13 | 20
12 | 2 | 20
8 | 14 | 3
14 | 11 | 18
6 | 11 | 14
19 | 12 | 3
8 | 7 | 13
8 | 3 | 20'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html