6

I'm trying to detect Russian characters with grep, but what I have at the moment does not appear to be doing anything:

 echo "Ёё" | grep -Eo "/[А-Яа-яЁё]/u"

No output is returned. Is there anything I have to do to tell grep to return the output?

6

there is no output because grep is looking for pattern /yourletters/u

try this:

  echo "Ёё" | grep -Eo "[А-Яа-яЁё]*"

test here:

kent$  echo "Ёё" | grep -Eo "[А-Яа-яЁё]*"
Ёё
7
  • Thanks! So I don't need to supply the /u modifier?
    – user429620
    Jan 28 '13 at 17:37
  • glad to know about the /u modifier.. what does it mean? I didn't find it in grep man page...
    – Kent
    Jan 28 '13 at 17:39
  • Well, in PHP it means that pattern strings are treated as UTF-8. I guess this is a default with grep? (since it does correctly output)
    – user429620
    Jan 28 '13 at 17:41
  • 1, you didn't tag the question as php. 2. I know nothing (almost) about php... :( If you want it to work with grep, you don't need it I guess.
    – Kent
    Jan 28 '13 at 17:43
  • 1
    You can use grep -f pattern.txt. Put your pattern to pattern.txt. This works with cyrillic. Oct 9 '13 at 5:59

Your Answer

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