Say it's very easy if I want to find something containing lower-case letters and numbers with
produce_text | grep -E '[0-9a-z]'
Brackets are useful to match a set of characters, but what about those that are somewhat special?
If I want to, using brackets, match any character but one of these: a closing bracket ]
, a dash (or hyphen) "-", both slashes /
and \
, a caret ^
, a colon :
.
Will it look like this (I know this doesn't work)?
[^]-/\^:]
awk
implementations andperl
for instance. – Stéphane Chazelas Feb 05 '17 at 01:58[^-]]
(This one fails)? – iBug Feb 06 '17 at 23:02^
is after]
so[^-]]
would not work even if both^
and]
were treated literally (just like[b-a]
). Anyway, if you wanted to match from e.g.;
to closing bracket you could use a range up to the char before]
(which is backslash) and include]
as first char in the bracket expression so e.g.[];-\\]
. – don_crissti Feb 06 '17 at 23:41[[.^.]-[.-.]]
? I have a feeling that this would work. Let's assume that the ASCII code of^
is before-
. – iBug Feb 07 '17 at 13:48[^[.].][.-.]/\^:]
– iBug Feb 07 '17 at 13:55