asp下正则实现URL自动链接的一个函数
网络编程
Function AutoLinkURLs(strString)
Dim match, matches, offset, url, email, link, relnkAutoLinkURL
relnkAutoLinkURL = "<a href=""[[%URL%]]"">[[%URLText%]]</a>"
If Not IsObject(regExp) Then Set regExp = New RegExp
regExp.Global = True
regExp.IgnoreCase = True
'Look for URLs
regExp.Pattern = "(((ht|f)tps?://)|(www.))([w-]+.)+[w-:]+(/[w- ./?%#;&=]*)?"
Set matches = regExp.Execute(strString)
offset = 0
For Each match in matches
url = match
If Left(url, 4) = "www." Then url = "http://" & url
link = Replace(Replace(relnkAutoLinkURL, "[[%URLText%]]", match), "[[%URL%]]", url)
strString = Mid(strString, 1, match.FirstIndex + offset) & link & Mid(strString, match.FirstIndex + 1 + match.Length + offset, Len(strString))
offset = offset + Len(link) - Len(match)
Next
'Look for emails
regExp.Pattern = "[A-Za-z0-9_+-.']+@w+([-.]w+)*.w+([-.]w+)*"
Set matches = regExp.Execute(strString)
offset = 0
For Each match in matches
email = match
link = Replace(Replace(relnkAutoLinkURL, "[[%URLText%]]", match), "[[%URL%]]", "mailto:" & email)
strString = Mid(strString, 1, match.FirstIndex + offset) & link & Mid(strString, match.FirstIndex + 1 + match.Length + offset, Len(strString))
offset = offset + Len(link) - Len(match)
Next
AutoLinkURLs = strString
End Function
JS:一个匹配日期的正则
(1[0-2]|0?[1-9])[-./](0?[1-9]|[12][0-9]|3[01])[-./](dddd)$1匹配10,11,12,01,02,03,04,05,06,07,08,09也是匹配月份$2匹配01,02...09,10,11....29,30,31也就是匹配日期$3匹配0000,0001....
正则表达式:过滤<font>和</font>
使用设计模式进行网页设计的时候经常会出现垃圾代码font和/font使用VisualStudio的查找替换功能可以将这些东西彻底消除CTRL+H打开替换功能选中正则表达
vbs:把一段文字中指定字符颜色变成红色的正则
vbs:把一段文字中指定字符颜色变成红色的正则functionc(Tstr,Word)DimreSetre=newRegExpre.IgnoreCase=Truere.Global=Truere.pattern=(&Word&)c=re.replace(Tstr,fontstyle='color:red;'$1/font)
编辑:一起学习网
标签:正则,中指,字符,红色,颜色