# Strange unicode regex behavior with Ruby 2.0

**URL:** <https://www.ruby-forum.com/t/strange-unicode-regex-behavior-with-ruby-2-0/227728>\
**Category:** Ruby\
**Created:** [March 26, 2013, 8:31pm UTC](https://www.ruby-forum.com/t/strange-unicode-regex-behavior-with-ruby-2-0/227728 "2013-03-26T20:31:52Z")\
**Posts on this page:** 4\
**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:** [March 26, 2013, 8:31pm UTC](https://www.ruby-forum.com/t/strange-unicode-regex-behavior-with-ruby-2-0/227728/1 "2013-03-26T20:31:52Z")

</div>

Hi,

the following code behaves strangely in ruby 2.0, and different from  
1.9:

puts “ä”.match(/[\p{Word}]/).inspect  
puts “ä”.match(/[\p{Word}\s]/).inspect

Result on 1.9.3-p194:  
#\<MatchData “ä”\>  
#\<MatchData “ä”\>

Result on 2.0.0-p0:  
#\<MatchData “ä”\>  
nil

Any ideas what’s going on there?

I have attached the ruby code as a file, in case there are any problems  
with email charset conversion.

Thanks!  
Andreas

---

<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:** [March 27, 2013, 6:54am UTC](https://www.ruby-forum.com/t/strange-unicode-regex-behavior-with-ruby-2-0/227728/2 "2013-03-27T06:54:39Z")

</div>

If a bug had been inserted, it appears it has been removed already:

$ ruby -v  
ruby 2.1.0dev (2013-03-25 trunk 39928) [x86\_64-linux]  
$ ruby test\_regex.rb  
#\<MatchData “ä”\>  
#\<MatchData “ä”\>

Carlo

---

<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:** [March 26, 2013, 9:17pm UTC](https://www.ruby-forum.com/t/strange-unicode-regex-behavior-with-ruby-2-0/227728/3 "2013-03-26T21:17:17Z")

</div>

Hey Andreas,

Lately, there have been some discussions on ruby-core (the mailing list  
dedicated to the core implementers of MRI). It’s possible that this bug  
is  
being adressed at the moment. These are the most recent messages there:

[http://blade.nagaokaut.ac.jp/ruby/ruby-core/53601-53800.shtml#latest](http://blade.nagaokaut.ac.jp/ruby/ruby-core/53601-53800.shtml#latest)

I don’t really know what could be causing this difference. ☹

* * *

Carlos A.  
Skype: carlos.agarie

Control engineering  
Polytechnic School, University of So Paulo, Brazil  
Computer engineering  
Embry-Riddle Aeronautical University, USA

2013/3/26 Andreas S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<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:** [March 27, 2013, 10:04pm UTC](https://www.ruby-forum.com/t/strange-unicode-regex-behavior-with-ruby-2-0/227728/4 "2013-03-27T22:04:54Z")

</div>

Thanks! Guess I will use a workaround for now and wait for 2.1.
