62,623
社区成员
发帖
与我相关
我的任务
分享String str = "hello, go to <a href=\"http://www.csdn.net\" aaa=\"aaaa.aa...dfa\">CSDN</a>." +
" for more info." +
" how are <hello name=\'java.import.com\' aa=\"adf.aad\\\"ad.asd.adf\" bb=\"abc.abc.add\">aaa</hello>you." +
" Good luck. ";
String regex = "(?<=\\w|>)(\\.)(?=\\s*)(?![^\"']*(\\\\.[^\"']*)*['\"][ >])";
String result = str.replaceAll(regex, "$1\n");
System.out.println(result);public class Test{
public static void main(String args[]) {
String str = "hello, go to <a href=\"http://www.csdn.net\" aaa=\"aaaa.aa...dfa\">CSDN</a>." +
" for more info." +
" how are <hello name=\'java.import.com\' aa=\"adf.aad\\\"ad.asd.adf\" bb=\"abc.abc.add\">aaa</a>you." +
" Good luck. ";
String regex = "(?<=\\.)\\s*(?![^\\\"']*(?:\\\\.[^\\\"']*)*['\"]\\s*[ >])";
String[] strs = str.split(regex);
for(String s : strs) {
System.out.println(s);
}
}
}