Imports?System.Text.RegularExpressions
創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括奇臺(tái)網(wǎng)站建設(shè)、奇臺(tái)網(wǎng)站制作、奇臺(tái)網(wǎng)頁制作以及奇臺(tái)網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,奇臺(tái)網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到奇臺(tái)省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
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?正則結(jié)果直接以字符串組形式返回
REM?strHtml待搜索的字符串
REM?strRegx正則表達(dá)式
REM?rexOpt正則選項(xiàng)
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?獲取正則表達(dá)式匹配的集合
REM?strHtml待正則的字符串
REM?strRegex正則表達(dá)式
REM?rexOpt正則選項(xiàng)
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?正則表達(dá)式文本替換
REM?sText原文本
REM?sRegex表達(dá)式
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
如圖:
Matches[1] 就是cc的數(shù)字
Matches[2] 就是bb的數(shù)字
[0]是整個(gè)字符串
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);
正則表達(dá)式是:
/[a-zA-Z/]+$
如果要把第一個(gè)斜杠去掉,就是匹配index/index/index,用后向匹配,正則是:
(?=/)[a-zA-Z/]+$