0
我有这样的HTML代码中的字符串:拆分HTML链接标签
Hello world
<img src="mypicture.png" />
<p>Some text in a tag</p>
<a href="http://www.google.fr">Link to google</a> Some Text <a href="http://www.yahoo.fr">Link to yahoo</a> End of line
<p>Some text in a tag</p>
<a attribute="some value" href="http://www.apple.com">Link to apple</a>
Some text
我想这个字符串转换成数组:
0 => Hello world
<img src="mypicture.png" />
<p>Some text in a tag</p>
<a href="
1 => http://www.google.fr
2 => ">Link to google</a> Some Text <a href="
3 => http://www.yahoo.fr
4 => ">Link to yahoo</a> End of line
<p>Some text in a tag</p>
<a attribute="some value" href="
5 => http://www.apple.com
6 => ">Link to apple</a>
Some text
我已经试过这个正则表达式。它工作正常提取的联系,但我不设法建立我的阵列...
<a (.*?)href=(.*?)\"(.+?)\"(.*?)>
尝试乐趣:'(?<= * href = \“)([^”] +)(?= \“[^>] *>) –
with regex.match? – Bob5421
使用'Regex.Split '。 –