$JAR_REPO/nlb/grbox/smnt.jar
I want to get the string between $ and first / and this will be replaced with some other string.
Please help.
Thanks. Wells
\$([^/]+)/.*
or, as a Java String:
"\\$([^/]+)/.*"
The JAR_REPO String will be the group(1)
:
Pattern pattern = Pattern.compile("\\$([^/]+)/.*");
Matcher matcher = pattern.matcher(yourstring);
if (matcher.find()) {
String jarRepo = matcher.group(1);
}
这种类型的递归解析方法可以与解析方法一起使用解释器模式逻辑来解决。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.