From: Davi Barbosa Date: 2008-10-14T05:23:23+09:00 Subject: Re: regexp with accent insensitive ?? Thank you for your answer, but I'm working with a lot of languages, so I don't know where someone can put an accent. For the moment, I just discovered that I can't remove the accents with Iconv like I said before. Here, it works only under irb.. I described this problem here: http://www.ruby-forum.com/topic/70827#738081 Another problem with utf-8 under ruby is that ruby can't index correctly the string. For example: '叩b'[2..2] gives the second half of '叩'. I discovered how to workaround using the unicode version of regexp: $KCODE = 'u' '叩b'.split(//m) == ["叩", "b"] Without these problems, I think that I know how to make it without false matchs with an ugly loop. If str and regexp are the versions without accents, str =~ regexp gives the position of the match and str[regexp].length the length. With these two numbers, It's possible to make the highlight in the original string. It's something like: ascii_string = Iconv.conv('US-ASCII//TRANSLIT','UTF-8',string) ascii_search = Iconv.conv('US-ASCII//TRANSLIT','UTF-8',search) regexp = Regexp.new(Regexp.escape(ascii_search),true) position = (ascii_string =~ regexp) size = ascii_string[regexp].length highlighted = ascii_string[0..(position-1)]+''+ascii_string[position..(position+size-1)]+''+ascii_string[(position+size)..-1] Of course, it need some modifications to put this in a loop (and I need to use the vector version of the string to index correctly the string). -- Posted via http://www.ruby-forum.com/.