[英]Pattern.compile with no flags?
我在文档中找不到这个。 我需要启用不区分大小写,但仅限于特殊情况。
如何调用方法Pattern.compile(String regex, int flags)
,使其等效于Pattern.compile(String regex)
? 我可以使用Pattern.compile("my regex", 0)
吗?
是的 - Pattern.compile(foo)
最终只返回Pattern.compile(foo, 0)
。
如果文档实际上说的那样会很好,但这就是我刚才看到的实现......
Pattern.compile(String regex)
的代码是(第1021行及以下):
public static Pattern compile(String regex) {
return new Pattern(regex, 0);
}
而Pattern.compile(String regex, int flags)
的代码是:
public static Pattern compile(String regex, int flags) {
return new Pattern(regex, flags);
}
是的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.