[TxMt] Re: how to match unicode?

James Gray james at grayproductions.net
Wed Sep 24 13:01:57 UTC 2008


On Sep 24, 2008, at 4:08 AM, Piero D'Ancona wrote:

> Writing a ruby command for TextMate to reformat author names
> in a list of papers I run into the obvious but sad fact that
> /[A-z]/ =~ "ü"
> does not match anything.  Is there a simple workaround?

If you set $KCODE = "U" in Ruby 1.8 (or pass the equivalent -KU  
switch) character classes like \w change to the Unicode definition of  
"word" characters:

$ ruby -KU -ve 'p "Résumé"[/\w+/]'
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin9.4.0]
"Résumé"

Hope that helps.

James Edward Gray II


More information about the textmate mailing list