From: Gianfranco Bozzetti Date: 2010-08-20T00:26:54+09:00 Subject: Re: ambiguous first argument? Roger Pack wrote: > Hi all. > With this code: > > memory_bitmap.scan /\x00{5}+/ > > I get this warning: > > test.rb:1: warning: ambiguous first argument; put parentheses or even > spaces > > Could somebody please help me to understand what exactly is ambiguous > there? > Thank you! > -r The ambiguity comes from the double quantifier {5}+ where: - {5} means exactly 5 occurrences of \x00 - + means 1 or more occurrences of preceding expression. Given the string: bitmap="\x30\x50\-\x00\x00\x00\x00\x00\x00\-\x40\x50\x30" p bitmap.scan(/\x00+/) #=> ["\000\000\000\000\000\000"] p bitmap.scan(/\x00{2}/) #=> ["\000\000", "\000\000", "\000\000"] HTH gfb -- Posted via http://www.ruby-forum.com/.