gpt4 book ai didi

java - 匹配从最后一个不在括号中的大写字母单词开始到字符串末尾的子串

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:18:58 25 4
gpt4 key购买 nike

我需要从不在括号内的最后一个前导(字首)大写字母到字符串末尾的子字符串

我尝试使用这个正则表达式:

([A-Z][a-zA-Z\-\']*\s*)*(\s+\([^)]*\)[\s]*)+$

匹配这个输入:

can This Be PosSible (Ignore aNy Upper CAse in parenthesis)

匹配是:

This Be PosSible (Ignore aNy Upper CAse in parenthesis)

但期望的输出是:

PosSible (Ignore aNy Upper CAse in parenthesis)

参见 this on regex101 .

最佳答案

这似乎适用于您的示例:

\b[A-Z](?![^(]*\))(?!.*\b[A-Z](?![^(]*\))).*

参见 live demo .

关于java - 匹配从最后一个不在括号中的大写字母单词开始到字符串末尾的子串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31251256/

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