gpt4 book ai didi

regex - 如何在 Google Docs 电子表格中使用 regexextract 函数来获取 "all"次出现的字符串?

转载 作者:行者123 更新时间:2023-12-04 00:53:11 34 4
gpt4 key购买 nike

我的文本字符串在单元格 D2 中:

Decision, ERC Case No. 2009-094 MC, In the Matter of the Application for Authority to Secure Loan from the National Electrification Administration (NEA), with Prayer for Issuance of Provisional Authority, Dinagat Island Electric Cooperative, Inc. (DIELCO) applicant(12/29/2011)

这个功能:
=regexextract(D2,"\([A-Z]*\)")

会抢(NEA)但不会(DIELCO)

我希望它同时提取 (NEA) 和 (DIELCO)

最佳答案

您可以使用捕获组,这将导致 regexextract()返回一个数组。您可以将其用作单元格结果,在这种情况下您将获得一系列结果,或者您可以将数组提供给另一个函数以根据您的目的重新格式化它。例如:

regexextract( "abracadabra" ; "(bra).*(bra)" )

将返回数组:
{bra,bra}

另一种方法是使用 regexreplace() .这样做的好处是替换是全局的(比如 s/pattern/replacement/g ),所以你不需要提前知道结果的数量。例如:
regexreplace( "aBRAcadaBRA" ; "[a-z]+" ; "..." )

将返回字符串:
...BRA...BRA

关于regex - 如何在 Google Docs 电子表格中使用 regexextract 函数来获取 "all"次出现的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8753930/

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