gpt4 book ai didi

asp.net - 正则表达式查找以 @ 开头的所有单词但忽略电子邮件地址

转载 作者:行者123 更新时间:2023-12-02 10:53:09 26 4
gpt4 key购买 nike

我创建了这个正则表达式来匹配字符串中以“@”开头的所有单词,@ 标记之前也可能有一些东西。它运行良好,但它也捕获电子邮件地址,我想解决这个问题。

(?<=@)\w+\b

示例字符串为:

hello @bob, how are you? @mark, @emma and @chief are with me. email me at test@email.com!

你能帮忙吗?

最佳答案

您可以使用下一个表达式:

\B@\w+

non-word boundary 开始(\B)。您还可以使用 negative lookahead 重写它像这样:

(?!\b)@\w+

关于asp.net - 正则表达式查找以 @ 开头的所有单词但忽略电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10044865/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com