通过标签位置递归解析标签 @param str @return
(String str)
| 38 | * @return |
| 39 | */ |
| 40 | private String parseOneLable(String str){ |
| 41 | String parseRes = ""; |
| 42 | String lable = str.substring(str.indexOf("<@")+2,str.indexOf(">")); |
| 43 | if(!lable.equals(null)&&!lable.trim().equals("")) { |
| 44 | String prefix = String.format("<@%s>", lable); |
| 45 | String suffix = String.format("</@%s>", lable); |
| 46 | String allContent = str.substring(str.indexOf(prefix), str.indexOf(suffix) + suffix.length()); |
| 47 | String subContent = str.substring(str.indexOf(prefix) + prefix.length(), str.indexOf(suffix)); |
| 48 | if (subContent.indexOf("<@") >= 0 && subContent.indexOf(">") >= 0) { |
| 49 | str = str.replace(subContent, parseOneLable(subContent)); |
| 50 | allContent = str.substring(str.indexOf(prefix), str.indexOf(suffix) + suffix.length()); |
| 51 | subContent = str.substring(str.indexOf(prefix) + prefix.length(), str.indexOf(suffix)); |
| 52 | parseRes = str.replace(allContent, encdoeLable(lable, subContent)); |
| 53 | } else { |
| 54 | parseRes = str.replace(allContent, encdoeLable(lable, subContent)); |
| 55 | } |
| 56 | } |
| 57 | return parseRes; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | /** |
no test coverage detected