|
@@ -441,17 +441,20 @@ public final class CommonUtils {
|
|
|
* @return
|
|
|
*/
|
|
|
public static String getAttrValue(String questionStr, String attrName) {
|
|
|
- Pattern pattern = Pattern.compile("a.*");
|
|
|
- Matcher matcher = pattern.matcher(questionStr);
|
|
|
- while (matcher.find()) {
|
|
|
- String result = matcher.group();
|
|
|
- String idstr = attrName + "=\".*?\"";
|
|
|
- Pattern pattern02 = Pattern.compile(idstr);
|
|
|
- Matcher matcher02 = pattern02.matcher(result);
|
|
|
- while (matcher02.find()) {
|
|
|
- return matcher02.group().replaceAll(attrName + "=\"", "").replaceAll("\"", "");
|
|
|
+ Pattern aPattern = Pattern.compile("a.*");
|
|
|
+ Matcher aMatcher = aPattern.matcher(questionStr);
|
|
|
+
|
|
|
+ if (aMatcher.find()) {
|
|
|
+ String idRegex = attrName + "=\".*?\"";
|
|
|
+ Pattern idPattern = Pattern.compile(idRegex);
|
|
|
+ Matcher idMatcher = idPattern.matcher(aMatcher.group());
|
|
|
+ if (idMatcher.find()) {
|
|
|
+ return idMatcher.group()
|
|
|
+ .replaceAll(attrName + "=\"", "")
|
|
|
+ .replaceAll("\"", "");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return "";
|
|
|
}
|
|
|
|