[英]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.