On 01.12.2022 11:30, Manuel Collado wrote:
The gawk manual says:
"To include one of the characters ‘\’, ‘]’, ‘-’, or ‘^’ in a bracket
expression, put a ‘\’ in front of it. For example:
[d\]]
matches either ‘d’ or ‘]’. Additionally, if you place ‘]’ right after
the opening ‘[’, the closing bracket is treated as one of the characters to be matched."
Don't know if this also applies to other awk variants.
The old Awk "Bible" says:
"Inside a character class, all characters have their literal meaning,
except for the quoting character \ , ^ at the beginning, and - between
two characters."
And for meta-characters generally it says that single meta-characters
match themselves, and otherwise need to be \-escaped to preserve their
literal meaning.
I suppose that's what we could expect from other including older awks.
(Test cases might be []], [[], vs. [\]], [\[].)
For more recent tools POSIX defines BRE bracket expressions for POSIX
awk, also mentioning the brackets. (WRT the bracket symbols it gets a
bit more complicated, though, with the collating syntaxes.)
Janis
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)