zoukankan      html  css  js  c++  java
  • ASP提取字段中的图片地址

     Function RegImg(TheStr)
        Dim RegEx
        Set RegEx = New RegExp '建立正则表达对象。
        RegEx.IgnoreCase =True ' 是否区分大小写,True为不区分且默认
        RegEx.Global = True '全部匹配还是只匹配第一个
        RegEx.Pattern = "<img[^>]*srcs*=s*['"&CHR(34)&"]?([w/-:.]*)['"&CHR(34)&"]?[^>]*>?" ' 搜索所使用的正则表达式
        If Regex.test(TheStr) Then  ' 判断是否有匹配值,返回True或者False。不受Global属性影响。
            Dim Matches
            Set Matches = RegEx.Execute(TheStr) ' 执行搜索。Execute 方法返回一个Matches 集合,其中包含了在 TheStr 中找到的每一个匹配的 Match 对象。如果未找到匹配,Execute 将返回空的 Matches 集合。
            For Each Match in Matches ' 遍历匹配集合。
            'RetStr = RetStr & Match.Value & "<br />" '获取整个img
            RetStr = RetStr & Match.SubMatches(0) '只取src
            Next
            RegImg = RetStr
        End If         
    End Function

  • 相关阅读:
    数据分析1-2
    数据分析1-1
    数据分析案例:
    数据分析1:安装tushare安装包
    小爬爬7:回顾&&crawlSpider
    小爬爬6: 网易新闻scrapy+selenium的爬取
    小爬爬6:中间件
    小爬爬6:2请求传参
    前端 -----jQuery的选择器
    前端 ----jQuery的介绍
  • 原文地址:https://www.cnblogs.com/mazey/p/6503524.html
Copyright © 2011-2022 走看看