the-king-of-cnblogs

ASP截取字符:
MID函数
Mid(变量或字串符,开始字节, 结尾字节(可不填)) 
InStrRev(变量, "字串符")  最后出现位置
InStr(变量, "字串符") 最先出现位置
(1)左部截取left(字符串,n):n是要截取的字符个数 
(2)中部截取Mid(字符串,p,n):表示从第p个字符开始截取n个字符 
(3)右部截取Right(字符串,n):表示截取字符串的后n个字符
如: 
left("abcdefg",3)的结果是:"abc" 
mid("abcdefg",2,3)的结果是:"bcd" 
right("abcdefg",3)的结果是:"efg" 
 
ASP截取指定字符之间的字符:
Function regx(patrn, str)
 Dim regEx, Match, Matches
 Set regEx = New RegExp
 regEx.Pattern = patrn
 regEx.IgnoreCase = True
 regEx.Global = True
 Set Matches = regEx.Execute(str)
 For Each Match in Matches
 RetStr = RetStr & Match.Value & " "
 Next
 regx = RetStr
End Function
调用: result=regx("http.*?jpg",str) \'这里的result就是你想要的结果.
 
 
ASP循环提取指定格式字符串:
do while instr(str,"<a htef")=0 
startnub=instr(str,"<a href") 
endnub=instr(str,"</a>") 
a(i)=mid(str,startnub,endnub-startnub) 
i=i+1 
str=mid(str,endnub+1) 
loop
Function RegExpTest(patrn, strng) \'首先是建个函数
Dim regEx, Match, Matches \' 建立变量。
Set regEx = New RegExp \' 建立正则表达式。
regEx.Pattern = patrn \' 设置模式。
regEx.IgnoreCase = True \' 设置是否区分字符大小写。
regEx.Global = True \' 设置全局可用性。
Set Matches = regEx.Execute(strng) \' 执行搜索。
For Each Match In Matches \' 遍历匹配集合。
RetStr = RetStr & Match.Value & "||"
Next
RegExpTest2 = RetStr
End Function
\'假设你的html的原文件信息存在变量 html中
href=RegExpTest(html,"<a href=(.*)>(.*)</a>") \'应该可以得到一个字符串变量href,将所有连接用||区分开,下面将其变为数组

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
  • 2022-01-26
  • 2022-02-03
  • 2022-02-01
  • 2021-11-22
猜你喜欢
  • 2021-10-11
  • 2022-02-21
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
相关资源
相似解决方案