gpt4 book ai didi

用于捕获星号之间内容的正则表达式,单词除外

转载 作者:行者123 更新时间:2023-12-05 00:45:41 24 4
gpt4 key购买 nike

在只能使用正则表达式的情况下,如何提取该字符串中除“NOT”以外的星号之间的文本?

* apple *  * orange tasty *  * banana *  * grape NOT *

预期结果:

apple

orange tasty

banana

最佳答案

您可以使用以下正则表达式:\*(\s*(?!NOT)\w+)+\s*\*

See explanation on regex101...

enter image description here

Here you can visualize your regular expression...

关于用于捕获星号之间内容的正则表达式,单词除外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56504137/

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