zoukankan      html  css  js  c++  java
  • ASP从编辑框中获取图片路径

    此函数可以将html代码里的所有图片路径读取出来,这样就可以将批量获取的图片路径保存到数据库,或者批

    量将图片打上水印,或者批量进行图片缩略,想怎么操作就怎么操作,这样就很方便了。
    如果路径是http://开头的,您还可以使用远程下载文件的函数进行下载。这样就做到了批量下载HTML代码时的

    远程图片或者文件了。
    Function oflink_lcasetag(imgstrng)
     '非凡设计原创361du.net
     '将内容html代码里的标签大写转换成小写
     Dim regEx, Match, Matches '建立变量。
     Set regEx = New RegExp '建立正则表达式。
     regEx.Pattern = "<.+?\>" '设置模式。
     regEx.IgnoreCase = true '设置是否区分字符大小写。
     regEx.Global = True '设置全局可用性。
     Set Matches = regEx.Execute(imgstrng) '执行搜索。
     imgstrng=imgstrng
     For Each Match in Matches '遍历匹配集合。
     imgstrng=replace(imgstrng,Match.Value,lcase(Match.Value))
     Next
     oflink_lcasetag = imgstrng
    End Function
    Function ofink_getsrc(strng)
     '非凡设计原创361du.net
     '批量获取图片路径
     strng=oflink_lcasetag(strng)
     Dim regEx, Match, Matches,values,if_add '建立变量。
     Set regEx = New RegExp '建立正则表达式。
     regEx.Pattern = "src\=.+?\.(gif|jpg|jpeg|jpe|png)"
     regEx.IgnoreCase = true '设置是否区分字符大小写。
     regEx.Global = True '设置全局可用性。
     Set Matches = regEx.Execute(strng) '执行搜索。
     if_add=0
     For Each Match in Matches '遍历匹配集合。
     values=values&Match.Value&"|"
     if_add=1
     Next
     values=replace(values,"src=""","")
     values=replace(values,"src='","")
     values=replace(values,"src=","")
     if if_add=1 then values=left(values,len(values)-1)
     ofink_getsrc = values
    End Function
    此函数使用方法:imglist=ofink_getsrc(content)
    其中content可以是编辑框中包含多张图片的内容
    imglist的结果就是将每个图片用"|"隔开,如:1.jpg|2.jpg|3.jpg
    得到这个结果后就可以使用split函数获取单个图片,要对这些图片做什么操作就自己想了。

    ASP 中 Split 函数的实例

    http://www.blueidea.com/tech/program/2003/734.asp

    如何把路径截取掉,只要文件名称?

      Dim   str,arrTmp    
      str="d:/cc/cc.rar"  
      arrTmp=   split(str,"/")  
      str=arrTmp(UBound(arrTmp))     
      response.write(str)  

  • 相关阅读:
    Web前端开发的一点记录
    关于表情符号与UTF-8的探讨
    微信公众号H5游戏本地搭建环境和调试(花生壳+wampserver+微信公众号测试号)
    ES6下的数组去重
    关于JS数组循环删除元素出现下标不对的问题
    好资源收藏
    ftp 操作,支持断点续传或者继续下载。
    推荐 greenrobot eventbus,简化安卓开发,提高安卓维护性,优化安卓性能
    T4模板TextTemplatingFileGenerator和TextTemplatingFilePreprocessor区别
    .net使用FluentValidation进行服务端验证。
  • 原文地址:https://www.cnblogs.com/zlmlovem/p/1687197.html
Copyright © 2011-2022 走看看