使用String.split()时 ,正则战可通过分组捕获实现:
String logs = "Error:404\nWarn:Timeout\n"; Pattern logPattern = Pattern.compile("(.*?表达)(\\n|$)"); Matcher matcher = logPattern.matcher(logs); while (matcher.find()) { System.out.println("Log: " + matcher.group(1)); }结语 ↓点击下方了解更多↓🔥《微信域名检测接口
