http://www.exampledepot.com/egs/java.util.regex/Line.html의 예는 나에게 두 번 거짓을 나타내지 만해야합니다! 왜?정규식 (Pattern.MULTILINE/(? m))의 라인 경계선 맞추기가 Java에서 중단 되었습니까?
CharSequence inputStr = "abc\ndef";
String patternStr = "abc$";
// Compile with multiline enabled
Pattern pattern = Pattern.compile(patternStr, Pattern.MULTILINE);
Matcher matcher = pattern.matcher(inputStr);
boolean matchFound = matcher.find(); // true
// Use an inline modifier to enable multiline mode
matchFound = pattern.matches(".*abc$.*", "abc\r\ndef"); // false
System.out.println(matchFound); // false
matchFound = pattern.matches("(?m).*abc$.*", "abc\r\ndef"); // true
System.out.println(matchFound);// false !!!!!
글쎄, 추가로 (? s) 넣으면 작동하지만 (? s) 없이는 작동하지 않아야합니까? 과거에 이런 행동이 바뀌 었습니까? 아니면 저자가 단순히 예제를 확인하지 않았습니까?
왜이 커뮤니티는 위키입니까? –