gpt4 book ai didi

java - 正则表达式中的 "\\p{all}"是什么意思?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:23:54 24 4
gpt4 key购买 nike

我正在使用一些 java 代码,其中包含以下语句:

if (sql1.matches("(?i)^CREATE\\s+TABLE\\p{all}*")) {
// do something;
}

我搜索了正则表达式语法,但找不到使用 \\p{all} 的规则。那么这个表达式是什么意思呢?

最佳答案

Unicode all 类别被“手动”添加到类别列表中以匹配任何字符,包括换行符等。

参见 Java regex source code :

map.put("all", new CharPropertyFactory() {
CharProperty make() { return new All(); }});

然后 this part :

/**
* Implements the Unicode category ALL and the dot metacharacter when
* in dotall mode.
*/
static final class All extends CharProperty {
boolean isSatisfiedBy(int ch) {
return true;
}
}

All() 用于以DOTALL 模式实例化.,见this part :

case '.':
next();
if (has(DOTALL)) {
node = new All();
} ....

关于java - 正则表达式中的 "\\p{all}"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51301255/

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