Discuz教程网

asp中获取内容中所有图片与获取内容中第一个图片的代码

[复制链接]
authicon dly 发表于 2011-9-14 09:00:34 | 显示全部楼层 |阅读模式
  1. '=====================================
  2. '获取内容中所有图片
  3. '=====================================
  4. Function Get_ImgSrc(ByVal t0)
  5. Dim t1,Regs,Matches,Match
  6. t1=""
  7. IF Not(IsNull(t0) Or Len(t0)=0) Then
  8. Set Regs=New RegExp
  9. Regs.Pattern="<img[^>]+src=""([^"">]+)""[^>]*>"
  10. Regs.Ignorecase=True
  11. Regs.Global=True
  12. Set Matches=Regs.Execute(t0)
  13. IF Matches.Count>0 Then
  14. For Each Match In Matches
  15. IF Left(Match.SubMatches(0),7)<>"http://" Then
  16. t1=t1&"<option value="""&Match.SubMatches(0)&""">"&Match.SubMatches(0)&"</option>"
  17. End IF
  18. Next
  19. End IF
  20. End IF
  21. Get_ImgSrc=t1
  22. Set Matches=Nothing
  23. Set Regs=Nothing
  24. End Function

  25. '=====================================
  26. '获取内容中第一个图片
  27. '=====================================
  28. Function Frist_Pic(ByVal t0)
  29. Frist_Pic=""
  30. Dim Regs,Matches
  31. Set Regs=New RegExp
  32. Regs.Ignorecase=True
  33. Regs.Global=True
  34. Regs.Pattern="<img[^>]+src=""([^"">]+)""[^>]*>"
  35. Set Matches=Regs.Execute(t0)
  36. IF Regs.test(t0) Then
  37. Frist_Pic=Matches(0).SubMatches(0)
  38. End IF
  39. Set Matches=Nothing
  40. Set Regs=Nothing
  41. End Function
复制代码




上一篇:Asp中通过简单的例子理解下ByVal和ByRef的用法
下一篇:获取一个数字的个位、十位、百位的函数代码
authicon 1314study 发表于 2012-11-14 12:47:15 | 显示全部楼层
路过!!!
不发表意见……
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 08:45

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表