re = /^((?!1|2|12|34).)*$/m
str = '0 ABCD
1 EFGH
2 IJKL
3 MNOP
4 ABCD
5 EFGH
6 IJKL
7 MNOP
8 ABCD
9 EFGH
10 IJKL
11 MNOP
12 ABCD
13 ABCD
...
AB 1 CD
...
31 EFGH
32 ABCD
33 ABCD
34 ABCD
35 ABCD
'
# 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