# Ruby 1.9.2: /\\w/u does not match umlauts ("Ã¼")

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-2-w-u-does-not-match-umlauts-a/195753>\
**Category:** Ruby\
**Created:** [September 29, 2010, 3:42pm UTC](https://www.ruby-forum.com/t/ruby-1-9-2-w-u-does-not-match-umlauts-a/195753 "2010-09-29T15:42:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [September 29, 2010, 3:42pm UTC](https://www.ruby-forum.com/t/ruby-1-9-2-w-u-does-not-match-umlauts-a/195753/1 "2010-09-29T15:42:36Z")

</div>

I found that, unlike Ruby 1.8, the word character class in Ruby 1.9  
regexes does not match german umlauts (or any other letters other than  
ASCII). According to the oniguruma documentation  
([サービス終了のお知らせ](http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt)), it should match  
everything from the unicode “letter” category, which includes umlauts.

test.rb (also attached):

# encoding: utf-8

$KCODE=‘u’  
s = “Ã¼”  
puts s.match(/\w/u).inspect

Result with ruby 1.8:  
#\<MatchData “Ã¼”\>

Result with ruby 1.9.2:  
nil

Is that a bug, or is there any reason behind this behavior?

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [September 29, 2010, 5:18pm UTC](https://www.ruby-forum.com/t/ruby-1-9-2-w-u-does-not-match-umlauts-a/195753/2 "2010-09-29T17:18:43Z")

</div>

After some more googleing I found this bug report (don’t know why I  
didn’t catch it earlier) that states that this is the desired behavior:  
[http://redmine.ruby-lang.org/issues/show/3181](http://redmine.ruby-lang.org/issues/show/3181)

Still, I don’t understand the motivation for making this change.

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [September 29, 2010, 5:59pm UTC](https://www.ruby-forum.com/t/ruby-1-9-2-w-u-does-not-match-umlauts-a/195753/3 "2010-09-29T17:59:05Z")

</div>

> [Ruby Talk FAQ · rdp/ruby\_tutorials\_core Wiki · GitHub](http://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#unicode_not_found)

“Basically at a certain patch level of 1.9.1, \w was set to no longer  
match unicode characters, because the core developers were concerned  
that this was not what people expected from \w.”

Well, 1.9.2 behaving differently than 1.9.1 and 1.8 is certainly less  
expected.

Apparently in 1.9 \p{Word} can be used instead of \w to match unicode  
characters; however I did not find any documentation for this (“word”  
it’s not a unicode character category).

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [September 29, 2010, 5:36pm UTC](https://www.ruby-forum.com/t/ruby-1-9-2-w-u-does-not-match-umlauts-a/195753/4 "2010-09-29T17:36:15Z")

</div>

Andreas S. wrote:

> I found that, unlike Ruby 1.8, the word character class in Ruby 1.9  
> regexes does not match german umlauts (or any other letters other than  
> ASCII). According to the oniguruma documentation  
> ([サービス終了のお知らせ](http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt)), it should match  
> everything from the unicode “letter” category, which includes umlauts.

> **[Ruby Talk FAQ](https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#unicode_not_found)**
>
> code examples to help enrich the documentation available for ruby's core classes ri output of the core classes - rdp/ruby\_tutorials\_core

so it’s intended, however if you extremely dislike this, then complain  
about it since apparently it’s surprising to a number of people 🙂

-r

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [September 29, 2010, 10:14pm UTC](https://www.ruby-forum.com/t/ruby-1-9-2-w-u-does-not-match-umlauts-a/195753/5 "2010-09-29T22:14:59Z")

</div>

> Well, 1.9.2 behaving differently than 1.9.1 and 1.8 is certainly less  
> expected.

yeah. 1.9.1 behaving differently with a different _patch level_ is less  
than expected, too.

> Apparently in 1.9 \p{Word} can be used instead of \w to match unicode  
> characters; however I did not find any documentation for this (“word”  
> it’s not a unicode character category).

That’s odd that there’s no standard. Maybe ruby made this up on their  
own, then?

I think it’s mentioned briefly

[http://svn.ruby-lang.org/repos/ruby/trunk/doc/re.rdoc](http://svn.ruby-lang.org/repos/ruby/trunk/doc/re.rdoc)

---

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [October 2, 2010, 3:56pm UTC](https://www.ruby-forum.com/t/ruby-1-9-2-w-u-does-not-match-umlauts-a/195753/6 "2010-10-02T15:56:58Z")

</div>

Andreas S.:

> Apparently in 1.9 \p{Word} can be used instead of \w to match unicode  
> characters; however I did not find any documentation for this (“word”  
> it’s not a unicode character category).

You can also use the (documneted) \p{L} property:

chastell@devielle:~$ ruby -ve “p ‘â„‰Ã¼Ã¼Ã¼’ =~ /\p{L}/”  
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86\_64-linux]  
1

BTW: I find [Regex Tutorial - Unicode Characters and Properties](http://www.regular-expressions.info/unicode.html#prop)  
most useful.

â€” Piotr S.
