编译带有多个标志的模式
import java.util.regex.Matcher;//时代Java - N o w J a v a . c o m import java.util.regex.Pattern; public class Main { public static void main(String[] args) { CharSequence inputStr = "Abc\ndef"; String patternStr = "abc$"; // Compile with multiline and case-insensitive enabled Pattern pattern = Pattern.compile(patternStr, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); boolean matchFound = matcher.find(); // true } }