ASP截取字符 截取字符之间的字符
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,將所有連接用||區分開,下面將其變為數組
轉載于:https://www.cnblogs.com/the-king-of-cnblogs/p/3475066.html
總結
以上是生活随笔為你收集整理的ASP截取字符 截取字符之间的字符的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 双缓冲法解决重绘和闪屏问题
- 下一篇: [大數據、Big Data、巨量資料、海