在下面的代码中我可以找到 <p|a|s>hello there</>
之间的任何文本比如获取p|a|s
和hello there
没有任何问题
Pattern mftA_REGEX = Pattern.compile("<(.+?)>(.+?)</>");
Matcher matcher = mftA_REGEX.matcher("<p|a|s>hello there</>");
if (matcher.find()) {
Log.e("tag ",matcher.group(1));
Log.e("text ",matcher.group(2));
}
现在当我没有p|a|s
时就像 <>hello there</>
匹配器找不到。在我的字符串中p|a|s
是可选的,我该如何更改Pattern.compile("<(.+?)>(.+?)</>");
解决这个问题?
最佳答案
关于java - 在自定义标签之间查找是否有文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43283572/