On Aug 20, 2009, at 6:37 PM, Juan Falgueras wrote:
desperate looking for a way of a more relaxed way of searching a string inside another, we need not to take into the account not only the case
s = "Abc" if s =~ /abc/i then …
but also if you have forgotten an accent, etc:
s = "áBc" if s =~ /abc/i then …also should match!
Changing the encoding to the simplest one: ASCII, does not work since iconv, nor ruby force_encoding() work and gives you errors in case you try to convert "á" to "a"
This might be one option for you:
$ irb -KU -r iconv
s = "áBc"
=> "áBc"
Iconv.conv("ASCII//TRANSLIT//IGNORE", "UTF-8",
s).downcase.delete("^a-z") =~ /abc/ => 0
I hope that helps.
James Edward Gray II