android怎么样摆脱图像标记的src值 [英] android how to get src value from image tag

查看:139
本文介绍了android怎么样摆脱图像标记的src值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的,我想从图像标签如下获得src属性值。

 < IMG的边界=0HEIGHT =430 src=\"http://2.bp.blogspot.com/-551kBiFcc3o/US2MxmAHq1I/AAAAAAAAZvM/DjurUt5-4Ac/s640/856738_537952452911181_897510449_o.jpg\" WIDTH =640>


解决方案

您可以尝试使用的常规EX pressions 来过滤掉IMG SRC的:

 字符串imgRegex ​​=< IMG [^>] + SRC \\\\ S * = \\\\ S * ['\\]([^'\\] +) '\\] [^]的计算值*>中;

您应该使用这个只有在<一个href=\"http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454\">you知道你在做什么(如CommonsWare在评论中指出)

剩下的就是你 - 你给我们介绍一下背景下的少量信息

In Android, I want to get value from src attribute from image tag as follow.

<img border="0" height="430" src="http://2.bp.blogspot.com/-551kBiFcc3o/US2MxmAHq1I/AAAAAAAAZvM/DjurUt5-4Ac/s640/856738_537952452911181_897510449_o.jpg" width="640">

解决方案

You can try using regular expressions to filter out img src's:

String imgRegex = "<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>";

You should use this only if you know what you're doing (as CommonsWare noted in the comments)

The rest is up to you - you've given us a little information about the context.

这篇关于android怎么样摆脱图像标记的src值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆