GNU sed doesn't seem to like PCRE musical notation:
...(?:...)...
Try:
s/\b[A-Za-z0-9._%-] +@ ([a-zA-Z0-9-]+\.)+(\.[A-Za-z]]{2,4})?\b/ email@example.com /
GNU sed looks like this. However, you still have a little work to do. Given the first line below as input, the output is the second line:
abc def@ghi.jk aaa abc email@example.comjk aaa
There are two problems giving this result:
]] must be one ] .- You are looking for the endpoint in the previous regular expression, so you do not want it in the last part of the domain suffix.
This task:
s/\b[A-Za-z0-9._%-] +@ ([a-zA-Z0-9-]+\.)+([A-Za-z]{2,4})?\b/ email@example.com / abc def@ghi.jk aaa abc email@example.com aaa
Jonathan leffler
source share