mystring = "
<div class="text">
Spor
</div>
";
pattern ="<div class=\"text\">(.*)</div>";
Pattern regEx = Pattern.compile(pattern, Pattern.MULTILINE);
Matcher m = regEx.matcher(myString);
if (m.find()) {
match = m.group(1);
} else {
match = "---";
}
不工作?
答案 0 :(得分:1)
默认情况下,'dot'字符不包含换行符
您必须使用Pattern.DOTALL
启用它。