Search code examples
regexawkgrepequivalence-classes

awk and equivalence classes


Does gnu awk support POSIX equivalence classes?

Is it possible to match [[=a=]] using awk as it is done in grep?

$ echo ábÅ | grep [[=a=]]
ábÅ

$ echo ábÅ | grep -o [[=a=]]
á
Å

Solution

  • Per the GAWK User's Guide, "Caution: The library functions that gawk uses for regular expression matching currently only recognize POSIX character classes; they do not recognize collating symbols or equivalence classes.".

    Accordingly, you're going to have to write-out the allowed equivalents in the regex /[aáÅ]/ or whatever you're looking for.

    There are locale-aware character ranges but that doesn't seem to be what you're asking about.