谁能建议我如何在以下字符串上应用正则表达式,以便它返回数组或任何出现在尖括号(<>)中的项目集合?
77+<99>*0.5+<100>+<101>+<99>*0.5+<100>+<101>
数组将包含
{99,100,101,100,101};
谢谢!
更新:(在不匹配之后)
// Compile regular expression
String patternStr = "(?<=<)(\\d+)(?=>)";
Pattern pattern = Pattern.compile(patternStr);
// Determine if there is an exact match
CharSequence inputStr = "77+<99>*0.5+<100>+<101>+<99>*0.5+<100>+<101>";
Matcher matcher = pattern.matcher(inputStr);
boolean matchFound = matcher.matches(); // false
System.out.println("...log..."+matchFound);