正则表达式匹配Java中的多行
Pattern.MULTILINE将有助于匹配Java中的多行。以下是显示此的示例-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MultiRegex {
public static void main(String[] args) {
if (args.length<1) {
System.err.println("run the program from command line");
System.exit(1);
}
String regexString = args[0];
String spamString = "welcome to java world";
Pattern aPattern = Pattern.compile(regexString,Pattern.MULTILINE);
Matcher aMatcher = aPattern.matcher(spamString);
if (aMatcher.find()) {
System.out.println("got a match");
} else {
System.out.println("no match");
}
}
}热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短