1
=~/\p{L}/

Rubularでテストすると、選択したバージョン 1.9.2 で動作します

しかし、irb:

>> RUBY_VERSION
=> "1.9.3"

?> "test test".match(/\p{L}/)
SyntaxError: (irb):3: invalid character property name {L}: /\p{L}/
    from C:/Ruby193/bin/irb:12:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

なんで?

4

1 に答える 1

1

それは実際に動作します:

1.9.3p385 :001 > "test test".match(/\p{L}/)
 => #<MatchData "t"> 
1.9.3p385 :002 > RUBY_VERSION
 => "1.9.3" 

あなたの問題は、Windowsのデフォルトのエンコーディングであるべきですか? 大文字と小文字を区別しますか? 狂気?

"test test".match(/\p{L}/u) 
 => #<MatchData "t"> 
"test test".match(/\p{L}/n) # same error you got 
SyntaxError: (irb):2: invalid character property name {L}: /\p{L}/
    from /home/fotanus/.rvm/rubies/ruby-1.9.3-p385/bin/irb:16:in `<main>'
于 2013-05-23T00:45:50.450 に答える