假设得到的授权羡拿码存于str中
方法一:
直接正颤派激则表达式提取授权码
Pattern pattern = Pattern.compile("\d+");
Matcher matcher = pattern.matcher(str);
String string = matcher.group(1);
方法二:
去除字符串中多余的html标签茄袜
Pattern pattern = Pattern.compile("<.+?>", Pattern.DOTALL);
Matcher matcher = pattern.matcher(str);
String string = matcher.replaceAll("");
方法一
String ResultString = null;
try {
Pattern regex = Pattern.compile("(.*)");
Matcher regexMatcher = regex.matcher(subjectString);
if (regexMatcher.find()) {
ResultString = regexMatcher.group();
}
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
如果上述ID不唯一可用以猛裤碰枝谈下方式
List
try {
Pattern regex = Pattern.compile("(.*)");
Matcher regexMatcher = regex.matcher(subjectString);
while (regexMatcher.find()) {
matchList.add(regexMatcher.group());
}
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
String regEx = "^(.*)