BREAK 在 JAVA 中使用正则表达式



我是使用正则表达式的新手 我想在 url 中获取 macapp 值,只需将数字 12 变为字符串,该怎么办?

String url = "stackoverflow.com/questions/ask:macapp=12";
Pattern pattern = ;// ?
Matcher matcher =;// ?

if(matcher.find()) 
{
//result = only 12
}
THX for your TIME
Pattern p = Pattern.compile("^.*:macapp=(\d+)$");
Matcher m = p.matcher(s);
if (m.find()) {
int n = Integer.valueOf(m.group(1));
...
}

最新更新