String jarString = "CLASSPATH=${RUNTIME}/app.jar:${RUNTIME}/site.jar:${RUNTIME}/dbgen.jar";
想得到app.jar site.jar和dbgen.jar
求正则表达式,谢谢
------解决方案--------------------
没试过,仅供参考。。
(.*\/([^\/:\$\{\}]*?\.jar))*
------解决方案--------------------
public static void main(String[] arg) {
List<String> imgList = new ArrayList<String>();
String intputStr ="CLASSPATH=${RUNTIME}/app.jar:${RUNTIME}/site.jar:${RUNTIME}/dbgen.jar";
Pattern pattern = Pattern.compile("/.+?(.jar)");
Matcher matcher = pattern.matcher(intputStr);
while (matcher.find()) {
imgList.add(matcher.group(0).replace("/", ""));
}
System.out.println(imgList);
}
------解决方案--------------------
public static void main(String[] arg) {
List<String> imgList = new ArrayList<String>();
String intputStr ="CLASSPATH=${RUNTIME}/app.jar:${RUNTIME}/site.jar:${RUNTIME}/dbgen.jar";
Pattern pattern = Pattern.compile("/(.+?(.jar))");
Matcher matcher = pattern.matcher(intputStr);
while (matcher.find()) {
imgList.add(matcher.group(1));
}
System.out.println(imgList);
}
这样也行