我已经知道了。
规则表达式包括要搜索的集合文本和描述如何搜索的特殊字符或命令。要初始化规则表达式搜索,就要生成RegExp对象并设置其Pattern属性。
如搜索"how are you"中的"you"字样:
dim s
dim rgxp
s="how are you"
set rgxp=New RegExp
rgxp.Pattern="you"
response.write rgxp.Text(s &"
'wirtes true
TEST方法返回TRUE或FALSE
EXECUTE返回一个MATCHES
其功能强大,下面则是比较复杂的一个脚本
(转):
function UBBCode(strContent)
if strAllowHTML <> 1 then
strContent = HTMLEncode(strContent)
end if
dim objRegExp
Set objRegExp=new RegExp
objRegExp.IgnoreCase =true
objRegExp.Global=True
if instr(strContent,"[vote]")>0 then
objRegExp.Pattern="(\[VOTE\])(\S+?)(\[\/VOTE\])"
strContent=objRegExp.Replace(strContent,"$2")
strContent=vote(strContent)
end if
objRegExp.Pattern="(\[URL\])(http:\/\/\S+?)(\[\/URL\])"
strContent= objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[URL\])(\S+?)(\[\/URL\])"
strContent= objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[URL=(http:\/\/\S+?)\])(.+?)(\[\/URL\])"
strContent= objRegExp.Replace(strContent,"
$3")
objRegExp.Pattern="(\[URL=(\S+?)\])(.+?)(\[\/URL\])"
strContent= objRegExp.Replace(strContent,"
$3")
objRegExp.Pattern="(\[EMAIL\])(\S+\@\S+?)(\[\/EMAIL\])"
strContent= objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[EMAIL=(\S+\@\S+?)\])(.+?)(\[\/EMAIL\])"
strContent= objRegExp.Replace(strContent,"
$3")
if locktopic="2" then
end if
if strflash= "1" then
objRegExp.Pattern="(\[FLASH\])(.+?)(\[\/FLASH\])"
strContent= objRegExp.Replace(strContent,"
")
end if
if strIcons = "1" then
objRegExp.Pattern="(\[em(.+?)\])"
strContent=objRegExp.Replace(strContent,"

")
' strContent= smile(strContent)
end if
if strIMGInPosts = "1" then
objRegExp.Pattern="(\[IMG\])(\S+?)(\[\/IMG\])"
strContent=objRegExp.Replace(strContent,"
![]()
")
end if
objRegExp.Pattern="(\[HTML\])(.+?)(\[\/HTML\])"
strContent=objRegExp.Replace(strContent,"
HTML 代码片段如下:
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]")
objRegExp.Pattern="(\[color=(.+?)\])(.+?)(\[\/color\])"
strContent=objRegExp.Replace(strContent,"
$3")
objRegExp.Pattern="(\[face=(.+?)\])(.+?)(\[\/face\])"
strContent=objRegExp.Replace(strContent,"
$3")
objRegExp.Pattern="(\[align=(.+?)\])(.+?)(\[\/align\])"
strContent=objRegExp.Replace(strContent,"
$3
")
objRegExp.Pattern="(\[QUOTE\])(.+?)(\[\/QUOTE\])"
strContent=objRegExp.Replace(strContent,"
quote:
$2
")
objRegExp.Pattern="(\[fly\])(.+?)(\[\/fly\])"
strContent=objRegExp.Replace(strContent,"
")
objRegExp.Pattern="(\[move\])(.+?)(\[\/move\])"
strContent=objRegExp.Replace(strContent,"
")
objRegExp.Pattern="(\[glow=(.+?),(.+?),(.+?)\])(.+?)(\[\/glow\])"
strContent=objRegExp.Replace(strContent,"
")
objRegExp.Pattern="(\[SHADOW=(.+?),(.+?),(.+?)\])(.+?)(\[\/SHADOW\])"
strContent=objRegExp.Replace(strContent,"
")
objRegExp.Pattern="(\[i\])(.+?)(\[\/i\])"
strContent=objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[u\])(.+?)(\[\/u\])"
strContent=objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[b\])(.+?)(\[\/b\])"
strContent=objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[fly\])(.+?)(\[\/fly\])"
strContent=objRegExp.Replace(strContent,"
")
objRegExp.Pattern="(\[size=1\])(.+?)(\[\/size\])"
strContent=objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[size=2\])(.+?)(\[\/size\])"
strContent=objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[size=3\])(.+?)(\[\/size\])"
strContent=objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[size=4\])(.+?)(\[\/size\])"
strContent=objRegExp.Replace(strContent,"
$2")
objRegExp.Pattern="(\[center\])(.+?)(\[\/center\])"
strContent=objRegExp.Replace(strContent,"
$2")
strContent = doCode(strContent, "
", "
")
strContent = doCode(strContent, "
", "
", "
", "
")
strContent = doCode(strContent, "
", "
", "
", "
")
strContent = doCode(strContent, "
", "[/*]", "", "")
strContent = doCode(strContent, "
", "
", "
", "
")
strContent=ChkBadWords(strContent)
set objRegExp=Nothing
UBBCode=strContent
end function