Imports?System.Text.RegularExpressions
創(chuàng)新互聯成立于2013年,是專業(yè)互聯網技術服務公司,擁有項目成都做網站、成都網站建設網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元元江縣做網站,已為上家服務,為元江縣各地企業(yè)和個人服務,聯系電話:18980820575
Public?Class?Form1
Public?Function?MadeRegexArray(ByVal?strText?As?String,?ByVal?strRegx?As?String,?ByVal?rexOpt?As?RegexOptions,?ByVal?Groups?As?Integer)?As?String()
REM?正則結果直接以字符串組形式返回
REM?strHtml待搜索的字符串
REM?strRegx正則表達式
REM?rexOpt正則選項
On?Error?Resume?Next
Return?MadeMatchString(MadeRegexMatch(strText,?strRegx,?rexOpt),?Groups)
End?Function
Public?Function?MadeMatchString(ByVal?mc?As?MatchCollection,?ByVal?Groups?As?Integer)?As?String()
REM?把MatchCollection以字符串組形式保存
REM?mc正則匹配的集合
REM?返回字符串組
On?Error?Resume?Next
Dim?strRegCode(mc.Count)?As?String
For?i?As?Integer?=?0?To?mc.Count?-?1
strRegCode(i)?=?mc(i).Groups(Groups).Value
Next?i
Return?strRegCode
End?Function
Public?Function?MadeRegexMatch(ByVal?strText?As?String,?ByVal?strRegex?As?String,?ByVal?rexOpt?As?RegexOptions)?As?MatchCollection
REM?獲取正則表達式匹配的集合
REM?strHtml待正則的字符串
REM?strRegex正則表達式
REM?rexOpt正則選項
REM?返回?MatchCollection?類型集合
On?Error?Resume?Next
Dim?rex?As?Regex?=?New?Regex(strRegex,?rexOpt)
Return?rex.Matches(strText)
End?Function
Public?Function?MadeRegexReplace(ByVal?sText?As?String,?ByVal?sRegex?As?String,?ByVal?sReplace?As?String)?As?String
REM?正則表達式文本替換
REM?sText原文本
REM?sRegex表達式
REM?sReplace替換文本
On?Error?Resume?Next
Dim?rex?As?Regex?=?New?Regex(sRegex,?RegexOptions.IgnoreCase)
Return?rex.Replace(sText,?sReplace)
End?Function
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
On?Error?Resume?Next
Dim?sRegex?As?String?=?"([\s\S]*?)"
Dim?aTable()?As?String?=?MadeRegexArray(TextBox1.Text,?sRegex,?RegexOptions.IgnoreCase,?1)
For?i?As?Integer?=?0?To?aTable.Length?-?1
TextBox2.Text?=?TextBox2.Text??aTable(i)
Next?i
End?Sub
End?Class
如圖:
在所給代碼基礎上僅作修改.
首先導入命名空間
Imports System.Text.RegularExpressions
然后:
Function geta(ByVal Str)
Dim re As New Regex("a(.+?)href=""*([^\s]+?)""*(\s|)")
Dim Contents As MatchCollection = re.Matches(Str)
Dim links As String = Nothing
For Each Match In Contents ' 遍歷匹配集合。
links = links + Match.SubMatches(1) + "|"
Next
geta = Mid(links, 1, Len(links) - 1)
geta = Replace(geta, "'", "")
re = Nothing
End Function
var reg = /;SPLIT(?:(?!;SPLIT)[\s\S])*;SPLIT/g;
var str = "";
str.replace(reg,"");
var?reg?=?/(.{4}年.{2}月.{2}日|.{2}年.{2}月.{2}日|[^\-]{2}\-[^\-]{2}|[^\/]{2}\/[^\/]{2}|[^\\]{2}\\[^\\]{2})/g;
var?str?=?"sdfasf****年**月**日,**年**月**日,**-**,**/**,**\**asdfadf";
str.match(reg);
Imports System.Text.RegularExpressions '引入命名空間
dim isTrue as boolean = regex.Match(textbox1.text, _
"(.*\x22.*\x22.*)|(.*\x27.*\x27.*)").Success
' 可匹配形如:"5648ffq" ,'454564565', 35235"ere"333, 434'ppp'89eru 等
'如果要匹配中文的“”、‘’
'改為:"(.*\u201C.*\u201D.*)|(.*\u2018.*\u2019.*)"