Sie können das -P
Flag für Perl-Regex und -i
für Groß- und Kleinschreibung nicht verwenden:
grep -Pi "[A-Z0-9][\w.%+-]+(?:@|@|\(at\)|\[at\]|%26%23064%3B|%40)[A-Z0-9][A-Z0-9.-]+\.[A-Z]"
\w
steht für [a-zA-Z0-9_]
Erläuterung:
[A-Z0-9] : 1 alphanum [\w.%+-]+ : 1 or more alphanum, _, ., %, + or - (?: : start non capture group @ : literally @ | : OR @ : html entity for @ | : \(at\) : | : \[at\] : | : %26%23064%3B : | : %40 : ) : [A-Z0-9] : 1 alphanum [A-Z0-9.-]+ : 1 or more alphanum, . or - \. : a dot [A-Z] : 2 upto 6 alpha (be aware that TLDs may have much more characters, see: https://www.iana.org/domains/root/db)
Ergebnis für gegebenes Beispiel:
grep -Pi "[A-Z0-9][\w.%+-]+(?:@|@|\(at\)|\[at\]|%26%23064%3B|%40)[A-Z0-9][A-Z0-9.-]+\.[A-Z]" file.txt info@example.com info@example.com info(at)example.com info[at]example.com info%26%23064%3Bexample.com info%40example.com