From: gotoken@... (GOTO Kentaro) Date: 2000-02-27T16:08:23+09:00 Subject: [ruby-talk:01593] Re: Certain char's not recognized by "." in regex? Hi, In message "[ruby-talk:01591] Certain char's not recognized by "." in regex?" on 00/02/26, Wes Nakamura writes: >(0..0xff).each { |i| > > r = Regexp.new(format("\\x%02x([\\xa1-\\xf3])", i)) > a = (i.chr() + "\xa2").sub(r, i.chr() + "\\1") > printf "0x%02x=%2d %s\n", i, (x = i.chr() =~ /./p).nil? ? -1 : x, a > >} Because Ruby's regexp is Japanese character code sensitive, some substrings are not matched by `/./'. I know three solutions. (1) Compile after `./configure --with-default-kcode=none' (2) $KCODE = "none" before pattern-matching. (3) Use non-Japanese character code regexp option `n': printf "0x%02x=%2d %s\n", i, (x = i.chr() =~ /./pn).nil? ? -1 : x, a Hope this helps -- gotoken