代码之家  ›  专栏  ›  技术社区  ›  chchrist

在闪存中提取字符串的一部分

  •  0
  • chchrist  · 技术社区  · 15 年前

    我有这根绳子

    <p><img src="http://www.foo.com/bar.jpg"></p><p>other content here</p>
    

    我需要提取SRC URL。img标记只出现在字符串的开头。

    事先谢谢。

    1 回复  |  直到 15 年前
        1
  •  0
  •   danii    15 年前

    可以使用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('"');
    

    SRC URL将是数组的第二个元素,因此:

    trace(a[1]);