(grep) Regex to match non-ASCII characters?

This will match a single non-ASCII character:

[^\x00-\x7F]

This is a valid PCRE (Perl-Compatible Regular Expression).

You can also use the POSIX shorthands:

  • [[:ascii:]] – matches a single ASCII char
  • [^[:ascii:]] – matches a single non-ASCII char

[^[:print:]] will probably suffice for you.**

Leave a Comment