62,614
社区成员
发帖
与我相关
我的任务
分享
String pTagA ="\\<img.*\\>.*\\<\\/img\\>";
Pattern tagAPattern = Pattern.compile(pTagA);
Matcher tagAMatcher = tagAPattern.matcher(content);
<img href='#' id='new'>超级链接</img>---两个标签的中间内容---<img href='#'>删除</img>
public class Test {
public static void main(String[] args) {
String str = "第一段\n第二段\n第三段";
str = str.replaceAll("(?m)^", "##");
System.out.println(str);
}
}
[^>]
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test {
public static void main(String[] args) {
String str = "排头兵--<img href='#' id='new'>超级链接</IMG>---两个标签的中间内容---<img href='#'>删除</img>后来居上,哈哈";
Pattern p = Pattern.compile("(?i)<img +[^>]+>.*?</img>");
Matcher m = p.matcher(str);
while(m.find()) {
System.out.println(m.group());
}
}
}