Reactormonk Reactormonk - 5 months ago 9
Ruby Question

How to match unicode words with ruby 1.9?

I'm using ruby 1.9 and trying to find out which regex I need to make this true:

Encoding.default_internal = Encoding.default_external = 'utf-8'
"föö".match(/(\w+)/u)[1] == "föö"
# => false

Answer
# encoding=utf-8 
p "föö".match(/\p{Word}+/)[0] == "föö"
Comments