集册 Java实例教程 编译带有多个标志的模式

编译带有多个标志的模式

欢马劈雪     最近更新时间:2020-01-02 10:19:05

399
编译带有多个标志的模式

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

  }

}