Using multiple constant fields

eriksan :

Apart from Pattern.CASE_INSENSITIVE, how do I also chose Pattern.MULTILINE in the call to Pattern.compile()?

Pattern tokenPattern = Pattern.compile("Hi", Pattern.CASE_INSENSITIVE);
Hovercraft Full Of Eels :

They are int flags, a bit-mask per the Pattern API, and so using bitwise-or, |, should work.

flags - Match flags, a bit mask that may include CASE_INSENSITIVE, MULTILINE, DOTALL, ...

For example:

Pattern tokenPattern = Pattern.compile("Hi", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);

To find many similar questions and answers, please check out this Google search link:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=114566&siteId=1