From: Jimmy Kofler Date: 2007-12-07T19:06:00+09:00 Subject: Re: Unicode in Regex > Re: Unicode in Regex > Posted by Jordan Callicoat (monkeesage) on 03.12.2007 02:50 > > This seems to work... > > $KCODE = "UTF8" > p /^[a-zA-Z\xC0-\xD6\xD9-\xF6\xF9-\xFF\.\'\-\ ]*?/u =~ "J�sp...it works" > # => 0 > ... > However, it looks to me like it would be more robust to use a slightly > modified version of UTF8REGEX (found in the link Jimmy posted > above)... > > UTF8REGEX = /\A(?: > [a-zA-Z\.\-\'\ ] > | [\xC2-\xDF][\x80-\xBF] > | \xE0[\xA0-\xBF][\x80-\xBF] > | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} > | \xED[\x80-\x9F][\x80-\xBF] > | \xF0[\x90-\xBF][\x80-\xBF]{2} > | [\xF1-\xF3][\x80-\xBF]{3} > | \xF4[\x80-\x8F][\x80-\xBF]{2} > )*\z/mnx Just to avoid confusion over the meaning of 'UTF8' in UTF8REGEX: the n option sets the encoding of UTF8REGEX to none! Cheers, j. k. -- Posted via http://www.ruby-forum.com/.