Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我的字符串看起来像这样时:
Something (foo@bar.com@baz.com) something...
如何获取foo@bar.com和baz.com使用正则表达式/grep?
foo@bar.com
baz.com
试试这个:
grep -Po '(?<=\()[^)]*(?=@)|(?<=@)[^)]*(?=\))'
用你的例子测试:
kent$ echo "Something (foo@bar.com@baz.com) something..."|grep -Po '(?<=\()[^)]*(?=@)|(?<=@)[^)]*(?=\))' foo@bar.com baz.com