1

当我的字符串看起来像这样时:

Something (foo@bar.com@baz.com) something...

如何获取foo@bar.combaz.com使用正则表达式/grep?

4

1 回答 1

0

试试这个:

grep -Po '(?<=\()[^)]*(?=@)|(?<=@)[^)]*(?=\))'

用你的例子测试:

kent$  echo "Something (foo@bar.com@baz.com) something..."|grep -Po '(?<=\()[^)]*(?=@)|(?<=@)[^)]*(?=\))'
foo@bar.com
baz.com
于 2013-07-16T15:22:14.563 回答