From: Ian Macdonald Date: 2007-02-14T05:19:59+09:00 Subject: Puzzling regex behaviour Hello, Can anyone explain this to me? $ echo $LANG nl_NL $ irb -f irb(main):001:0> foo = "pr�f�r�es" => "pr\351f\351r\351es" irb(main):002:0> foo =~ /[^[:alnum:]]/ => nil irb(main):003:0> foo =~ /\W/ => 2 First question: Why does the final statement return 2 instead of nil? All characters in foo are alphabetic characters in this locale. Then: $ echo $LANG nl_NL $ cat ./foo #!/usr/bin/ruby -w foo = "pr�f�r�es" p foo =~ /[^[:alnum:]]/ p foo =~ /\W/ $ ./foo 2 2 Huh? Second question: Why does the first regex match now return 2 instead of nil? To my way of thinking, both statements should always return nil, whether or not they are typed into irb or run in a stand-alone script. At the very least, both statements should return the same answer, regardless of the context. What am I missing here? Ian -- Ian Macdonald | tachyon emissions overloading the system ian@caliban.org | http://www.caliban.org/ | | |