Jes*_*Jes -4 java string split
我想提取给定字符串的子字符串.示例字符串是rta=0.037ms;3000.000;5000.000;0; pl=10%;80;100;; rtmax=0.125ms;;;; rtmin=0.012ms;
我想在"rta ="后只有0.037ms,在pl =后只有%.我试图用空格然后用分号拼接上面的字符串.不工作.
小智 5
String s = "rta=0.037ms;3000.000;5000.000;0; pl=10%;80;100;; rtmax=0.125ms;;;; rtmin=0.012ms;";
Pattern pattern = Pattern.compile("rta=(.*?);.*pl=(.*?);");
Matcher matcher = pattern.matcher(s);
if(matcher.find()){
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
}
Run Code Online (Sandbox Code Playgroud)