7
$\begingroup$

Why does the code

StringMatchQ["ы", LetterCharacter]

return False?

Probably because:

StringMatchQ["ы", LetterCharacter] // HoldForm // FullForm
(*HoldForm[StringMatchQ["\:044b",LetterCharacter]]*)

How can I use the LetterCharacter pattern with Cyrillic symbols?

$\endgroup$
  • 6
    $\begingroup$ I have notified WRI about this problem in August. But this problem still persists in 10.0.2. Also there are problems with ToUpperCase, ToLowerCase and other functions that use option IgnoreCase (LongestCommonSequence, SequenceAlignment). Sort in some cases also didn't work with russian letters correctly. $\endgroup$ – Alexey Golyshev Dec 27 '14 at 10:03
  • $\begingroup$ Hi ! Although informative this does not answer the question at hand. It is better suited as a comment and also contains a mistake. The so called Cyrillic letters are not Russian :) $\endgroup$ – Sektor Dec 27 '14 at 10:17
7
$\begingroup$

Your code

StringMatchQ["ы", LetterCharacter]

returns False, because only the following characters are treated as letters:

StringJoin[Select[Characters[FromCharacterCode[Range[2^16 - 1]]], LetterQ]]

letters

and LetterCharacter only matches the characters for which LetterQ gives True.
You can include Cyrillic symbols using:

StringMatchQ["ы", LetterCharacter | RegularExpression["[А-я]"]]
True

Or define your own

letterCharacter = LetterCharacter | RegularExpression["[А-я]"]

StringMatchQ["ы", letterCharacter]
True
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.