Hello,
I have a Ruby aplication that deals with non-english text and I want to
transform some of that text to [^a-zA-Z0-9].
Examples:
búsqueda -> busqueda
presenças -> presencas
für -> fur
avião1 -> aviao1
I don’t think there is a unified mapping table to transform
non-[^a-zA-Z0-9]
characters into a specific one of them. But if you can concider to write
a
map yourself try something like:
class String
MAP = [[/ü/, ‘u’],
[/ö/, ‘o’]]
def eng_char
res = String.new(self)
MAP.each { |r| res = res.gsub(r[0],r[1]) }
return res
end
I don’t think there is a unified mapping table to transform
non-[^a-zA-Z0-9]
characters into a specific one of them. But if you can concider to write
a
map yourself try something like:
class String
MAP = [[/ü/, ‘u’],
[/ö/, ‘o’]]
def eng_char
res = String.new(self)
MAP.each { |r| res = res.gsub(r[0],r[1]) }
return res
end
end
s = “abücüöö”
puts s + " => " + s.eng_char
Will output:
abücüöö => abucuoo
Martin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.