I couldn't find this in the documentation. I need to enable case insensitivity, but only in special cases.
How do I call the method Pattern.compile(String regex, int flags)
in such a way that it is equivalent to Pattern.compile(String regex)
? Can I just use Pattern.compile("my regex", 0)
?
Yes - Pattern.compile(foo)
ends up just returning Pattern.compile(foo, 0)
.
It would be nice if the documentation actually said that, but that's what the implementation I just looked at does...
Can I just use
Pattern.compile("my regex", 0)
?
Yes. The javadoc says
flags - Match flags, a bit mask that may include CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, CANON_EQ, UNIX_LINES, LITERAL, UNICODE_CHARACTER_CLASS and COMMENTS
0 is the bitmask containing no bits.
I need to enable case insensitivity, but only in special cases.
There are a few different kinds of case-sensitivity available with Pattern
.
For more fine-grained control over case-sensitivity, you might need to do your own case folding or collation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With