Mailinglist Archive: opensuse-ruby (1 mails)

< Previous Next >
[opensuse-ruby] regexp and unicode
  • From: Marcus Rueckert <darix@xxxxxxxxx>
  • Date: Tue, 30 Mar 2010 14:38:31 +0200
  • Message-id: <20100330123831.GA7401@xxxxxxxxxxxx>
hi,

Michael Calmer ran into a bug with regexp in ruby 1.8.[1]

Rails sets the $KCODE variable to UTF-8, which changes the meaning of
the \w class.

To quote answer in the bug:
[[[
Ruby 1.8's /\w/u matches [0-9a-zA-Z_] and all non ASCII of Unicode.
]]]

In Ruby 1.9 and JRuby this part of the ruby spec changed and behaves as
expected.

So if you use regexp validations, make sure to keep to use [A-Za-z0-9_]
instead of \w.

hth

darix

[1] http://redmine.ruby-lang.org/issues/show/3047

--
openSUSE - SUSE Linux is my linux
openSUSE is good for you
www.opensuse.org
--
To unsubscribe, e-mail: opensuse-ruby+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-ruby+help@xxxxxxxxxxxx

< Previous Next >
List Navigation
This Thread
  • No further messages