I have this string
我有这个字符串
<p><img src="http://www.foo.com/bar.jpg"></p><p>other content here</p>
I need to extract the src url . The img tag appears only at the beggining of the string.
我需要提取src url。 img标记仅出现在字符串的开头。
Thanks in advance.
提前致谢。
1 个解决方案
#1
0
You can use String.split:
你可以使用String.split:
var s:String = "<p><img src=\"http://www.foo.com/bar.jpg\"></p><p>other content here</p>";
var a:Array = s.split('"');
The src url would be the 2nd element of the array, so:
src url将是数组的第二个元素,因此:
trace(a[1]);
#1
0
You can use String.split:
你可以使用String.split:
var s:String = "<p><img src=\"http://www.foo.com/bar.jpg\"></p><p>other content here</p>";
var a:Array = s.split('"');
The src url would be the 2nd element of the array, so:
src url将是数组的第二个元素,因此:
trace(a[1]);