您可以
Pattern为此使用类。如果您只想在中匹配单词字符,
{}则可以使用以下正则表达式。w是的简写
[a-zA-Z0-9_]。如果您可以,请
_使用
w或
[a-zA-Z0-9]。
String URL = "https://localhost:8080/sbs/01.00/sip/dreamworks/v/01.00/cui/print/$fwVer/{$fwVer}/$lang/en/$model/{$model}/$region/us/$imageBg/{$imageBg}/$imageH/{$imageH}/$imageSz/{$imageSz}/$imageW/{$imageW}/movie/Kung_Fu_Panda_two/categories/3D_Pix/item/{item}/_back/2?$uniqueID={$uniqueID}";Pattern pattern = Pattern.compile("/\{\w+\}/");Matcher matcher = pattern.matcher(URL);if (matcher.find()) { System.out.println(matcher.group(0)); //prints /{item}/} else { System.out.println("Match not found");}


