我的文本字符串位于单元格 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)