Daniel DeLorme
9/21/2006 12:01:00 AM
Richard Wiseman wrote:
> puts "Pattern includes \"[x\xa3]\":"
> text.scan(/^[x\xa3]?[A-Z]$/).each {|s| puts s }
That is very weird indeed. It's normal that your example doesn't work, because
\xa3 is NOT valid utf8. But I would've expected it to work if you used the
correct utf8 sequence for "ú" ("\xc3\xba"), except it doesn't!
$KCODE='u'
=> "u"
text = "\xc3\xbaA\nB\n\xc3\xbaC\nxD\nE"
=> "úA\nB\núC\nxD\nE"
text.scan(/^[xú]?[A-Z]$/)
=> ["úA", "B", "úC", "xD", "E"]
text.scan(/^[x\xc3\xba]?[A-Z]$/)
=> ["B", "xD", "E"]
WTF? Can anyone explain this?