我对正则表达式很愚蠢,所以我快速而肮脏地解决了它:
private void readOffset(){
String offset = manager.get("offset");
String v1 = offset.substring(offset.indexOf("{")+1, offset.indexOf("}"));
String v2 = offset.substring(offset.lastIndexOf("{")+1, offset.lastIndexOf("}"));
multiplikator.setValue(v1);
divisor.setValue(v2);
/*
RegExp regExp = RegExp.compile(".*({\\d+}).*", "g");
MatchResult matcher = regExp.exec(offset);
boolean matchFound = (matcher != null);
if(matchFound == true && matcher.getGroupCount() == 2){
String val1 = matcher.getGroup(0);
String val2 = matcher.getGroup(1);
multiplikator.setValue(matcher.getGroup(0));
divisor.setValue(matcher.getGroup(1));
}else{
multiplikator.setValue("1");
divisor.setValue("1");
}
*/
}
欢迎更好的解决方案:(