提取 '@' 之后的子字符串Google Sheets 中用于推文分析的字符

发布于 2025-01-11 02:13:25 字数 365 浏览 4 评论 0原文

我正在使用以下公式尝试从 B 列中提取子字符串 @sizzlegg@fckoeln_en!,问题是在使用 REGEXTRACT 识别 ' @' 象征。

我需要它直接提取“@”(at/标签符号)之后的任何内容,无论 B 列中值文本的长度或紧随该符号之后的子字符串的长度。

=REGEXEXTRACT(B18,".*@(.*)")

Google 表格行的屏幕截图

I am using the following formula trying to extract the substring @sizzlegg and @fckoeln_en! from column B, the problem is that I get an error when using REGEXTRACT to identify the '@' symbol.

I need it to extract anything straight after the '@' (at/tag symbol) no matter the length of the value text in column B or the length of the substring immediately after the symbol.

=REGEXEXTRACT(B18,".*@(.*)")

Screenshot of Google Sheet rows

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北城孤痞 2025-01-18 02:13:25

尝试

=REGEXEXTRACT(A1,REGEXREPLACE(A1,"(@\w+)","($1)"))

enter图片描述在这里

解释

  • 首先,识别字母数字字符([a-zA-Z0-9_]),后面跟@并在=>周围添加括号;这样我们就会得到一个正则表达式 =REGEXREPLACE(A1,"(@\w+)","($1)")

  • 然后,使用该正则表达式通过 =regexextract(A1,正则表达式)

请注意,

如果 A1 中已有括号 (),则必须将其删除第一的

=REGEXEXTRACT(REGEXREPLACE(A1,"\(|\)",""),REGEXREPLACE(REGEXREPLACE(A1,"\(|\)",""),"(@\w+)","($1)"))

Try

=REGEXEXTRACT(A1,REGEXREPLACE(A1,"(@\w+)","($1)"))

enter image description here

explantation

  • first, identifiy alphanumeric characters ([a-zA-Z0-9_]) following with @ and add parentheses around => thus we will get a regular expression =REGEXREPLACE(A1,"(@\w+)","($1)")

  • then, use that regular expression to extract these alphanumeric characters with =regexextract(A1,regular expression)

note

if you have already parentheses () in A1, you have to remove them first

=REGEXEXTRACT(REGEXREPLACE(A1,"\(|\)",""),REGEXREPLACE(REGEXREPLACE(A1,"\(|\)",""),"(@\w+)","($1)"))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文