fck值的截取
fck的值存的是如下的html格式的,我想取得第一个img标记内的值:比如
<img src= "../images/m-l-1.jpg " width= "9 " height= "10 " />
请问该怎么截取?
<b> nbsp; 在 <font color= "red "> .NET技术 ASP.NET </font> 社区发表新贴子:
<a href= "/Expert/help/usehelp.htm " target= "_blank "> 使用说明 </a> <img src= "../images/m-l-1.jpg " width= "9 " height= "10 ">
<br>
<font color= "red "> (请您对您的言行负责,遵守中华人民共和国有关法律、法规,尊重网上道德) </font> </b>
<br>
发表问题前,建议搜索已有问题: <a href= "http://search.csdn.net/ " target= "_blank "> http://search.csdn.net/ </a>
<hr> <img src= "../images/m-l-2.jpg " width= "9 " height= "10 ">
------解决方案--------------------正则表达式 表达式我写不来 你发个贴问问
如果你是用javascript的话,直接doucment.getElementsByTagName( 'img ')[0].getAttribute( 'src ')就行
------解决方案--------------------给一个asp.net1.1 vb.net的例子给你研究学习用
<%@ Page validateRequest= "false " %>
<script language= "VB " runat= "server ">
Sub Enter_Click(Sender As Object, E As EventArgs)
Call SearchSrc(txtContent.Text) '调用函数,输出所有匹配项
End Sub
Sub SearchSrc(strInput As String)
Dim r As Regex
r=New Regex( "src\s*=\s*( " "([^ " "]*) " "|(\S+)) " , RegexOptions.IgNoreCase)
Dim mc As MatchCollection '定义MatchCollection变量
mc=r.Matches(strInput) '返回所有匹配项
message.Text = "共找到 " & mc.Count & "个匹配项 "
Dim I As Integer,m As Match
For I=0 To mc.Count-1
m=mc.Item(I) '返回集合中的第I个匹配项
message.Text &= " <br> 位置 " & m.Index.ToString()
message.Text &= "地址 " & m.Value
Next
End Sub
</script>
<html>
<body>
<