[英]Extract substring from string Android
I have string like this: 我有这样的字符串:
<a hidden="true" href="xxx" class=" zt-uie-session </a>
How to extract href value in Android? 如何在Android中提取href值? It's string, not some object.
它是字符串,而不是对象。
Try below code it is working fine 试试下面的代码,它工作正常
String str = "<a hidden=\"true\" href=\"xxx\" class=\" zt-uie-session></a>";
Matcher m = Pattern.compile(" (?:href)=\"([^\"]+)").matcher(str);
while (m.find()) {
String result = m.group(1);
Log.d("HREF",": "+result); //result is "xxx"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.