re = /^(.{20})[^.]{4,}(.*)$/mi
str = '1.1234567890.ab
2.123456789012345678901.ab
3.1234567890123456789012.ab
4.12345678901234567890123.ab
5.123456789012345678901234.ab
6.1234567890123456789012345.ab
7.12345678901234567890123456.ab
8.123456789012345678901234567890.ab
9.123456789012345678901234567890.1234567890123456.7890.ab
0.123456789012345678901234567890.12345678901.234567890....abcdef012345
12345678901234567890123456789012345678901234567890'
# 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