From: Brian Candler Date: 2010-05-10T22:58:27+09:00 Subject: Re: Issue with regular expressions and locales Emili Parre単o wrote: > In my local system I get this > > "多" =~ /\W/ > => 0 > > but in another systems with english locale I have this other result > > "多" =~ /\W/ > => nil > > Is this a bug or regular expressions matching depends on system locale? (1) What exact version(s) of Ruby are you running? (Show RUBY_DESCRIPTION constant). Behaviour varies between versions. (2) What does "多".encoding show on the two machines? AFAIK the actual match should depend only on the encoding of the string, not the system locale in the environment - but if you find differently that would be of interest. (3) It looks like you are doing this in IRB. IRB is not a good predictor of behaviour in ruby 1.9, since the encoding of string literals in IRB depends on the system locale - which is not true for ruby source code in source files. So writing a small test .rb file and running that is probably better. I've attempted to document what I've found so far about encoding behaviour in 1.9 here: http://github.com/candlerb/string19/blob/master/string19.rb -- Posted via http://www.ruby-forum.com/.