Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, alpha doesn't work, at least in "grep -P" with "ru_RU.UTF-8" locale:

  $ echo Test | grep -oP '[[:alpha:]]+'
  Test
  $ echo Артём | grep -oP '[[:alpha:]]+'
  $ echo Артём | grep -oP '[А-Яа-я]+'
  Арт
  м
This thing works, though I've never seen one in the wild:

  $ echo Артём | grep -oP '[\p{Cyrillic}]+'
  Артём


Standard classes only work for 8-bit locales, afaik, and also in some languages (e.g. perl) when a string encoding corresponds to an internal representation of what its engine thinks it is a "current" unicode format for the specific version of language and a checkout location. The fact that different tools stick to different engines, modes and normalization rules (bre/ere/posix/nfd/nfc/perl/pcre/php/ruby/icu/whatever) doesn't help either. Full cross-platform unicode matching is a can of worms that you usually don't want to open. It is basically CSV of the encoding world. /\S+?/ to the rescue.

https://regular-expressions.mobi/unicode.html

https://regular-expressions.mobi/refunicode.html

https://regular-expressions.mobi/posixbrackets.html


Well, that is horrifying. TIL.


  $ echo Артём | grep -oE '[[:alpha:]]+'
  Артём


Yep, -E vs. -P




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: