62,634
社区成员




import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Test{
public static void main(String[] args){
String content = "new line\n"+
"__new001_tag00_tag\n"+
"#SW\n"+
"this is news 001\n"+
"abbbbbbbbbbbb\n"+
"new line\n"+
"__new001_tag00_tag\n"+
"#SW\n"+
"this is news 002\n"+
"abbbbbbbbbbbb\n"+
"new line\n"+
"new line\n"+
"__new001_tag00_tag\n"+
"#SW\n"+
"this is news 003\n"+
"abbbbbbbbbbbb\n";
String regex = "(?s)(?:new line\n)(.*?)(?=new line\n)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(content);
if(matcher.find()){
System.out.println(matcher.group(1));
}
}
}