使用正则表达式的 “零宽度正回顾后发断言“这个正则就是匹配以某个指定字符开头的字段,具体定义你可以去搜索一下,java代码如下:String target = "scoreboard objectives setdisplay sidebar R_HT_win";Pattern pattern = Pattern.compile("(?<=scoreboard objectives setdisplay sidebar\\s{1})\\w*");Matcher matcher = pattern.matcher(target);String result = null;if (matcher.find()){int startIndex = matcher.start();int endIndex = matcher.end();result = target.substring(startIndex,endIndex);}System.out.println(result);