当我的字符串看起来像这样:
Something (foo@bar.com@baz.com) something...
如何使用regex / grep获取foo@bar.com
和baz.com
?
答案 0 :(得分:0)
试试这个:
grep -Po '(?<=\()[^)]*(?=@)|(?<=@)[^)]*(?=\))'
用你的例子测试:
kent$ echo "Something (foo@bar.com@baz.com) something..."|grep -Po '(?<=\()[^)]*(?=@)|(?<=@)[^)]*(?=\))'
foo@bar.com
baz.com