Reputation: 20045
Using java.util.regex.Pattern.compile()
you can specify a pattern as parameter. But how can you specify flags like case-insensitive and ignore whitespaces as well?
Upvotes: 2
Views: 840
Reputation: 21300
java.util.regex.Pattern.compile(String regex, int flags);
Parameters:
regex
, the expression to be compiled flags Match flags
, a bit maskYou can set flags
to a bitmask composed by
CASE_INSENSITIVE
MULTILINE
DOTALL
UNICODE_CASE
CANON_EQ
UNIX_LINES
LITERAL
COMMENTS
Upvotes: 3
Reputation: 10115
You can use the Pattern.compile(String regex, int flags) method that takes flags as well, or you can put them in your Pattern itself:
Eg.
Pattern.compile("(?i)a");
Upvotes: 4
Reputation: 24801
Pattern pattern = Pattern.compile(patternStr, Pattern.CASE_INSENSITIVE);
Upvotes: 3