@redcodefinal/

Regex Test

Ruby

No description

fork
loading
Files
  • main.rb
main.rb
1
2
3
4
5
6
7
8
9
good_header = "ABCDEFGHIJKLMNOPQRST"
bad_header = "ABCDEFGHIJKLMNOP\x93\x92JO"
puts "Header Sizes: #{good_header.size}, #{bad_header.size}"
good_input = good_header + "!!!!!!!!!!"
bad_input = bad_header + "!!!!!!!!!!"
regex = Regexp.new('(?<=.{20})(.+)', Regexp::NOENCODING)

puts "Good: #{good_input.match regex}"
puts "Bad: #{bad_input.match regex}"
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]