Project

General

Profile

Bug #9517

why not match ?

Added by kk kk almost 3 years ago. Updated over 2 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
ruby -v:
ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux]
[ruby-core:60687]

Description

class String
  def jhex
    self.split(/,|\s+/).map{|x| x.hex}.pack('c*')
  end
end
s  = "01 00 28 09 00 04 02 00 27 AA" .jhex
s1 = "01 00 05 09 00 04 02 00 0A AA" .jhex

s .force_encoding 'ascii-8bit'
s1.force_encoding 'ascii-8bit'

r = Regexp.new '[\001\002\003]\000(.*?)\xAA' , nil , 'n'

s .match(r)   #=> #<MatchData "\x01\x00(\t\x00\x04\x02\x00'\xAA" 1:"(\t\x00\x04\x02\x00'">
s1.match(r)   #=> nil  #why?


History

#1 [ruby-core:60689] Updated by Heesob Park almost 3 years ago

I think this issue is not a bug.

Because s1 string contains "\n" character, the match fails.
Try with
r = Regexp.new '[\001\002\003]\000(.*?)\xAA' , Regexp::MULTILINE , 'n'

#2 [ruby-core:60690] Updated by kk kk almost 3 years ago

ok, why not set Regexp::MULTILINE by default ?

#3 [ruby-core:64337] Updated by Hiroshi SHIBATA over 2 years ago

  • Status changed from Open to Rejected

Also available in: Atom PDF