您的位置:首页 > 编程语言 > ASP

asp字符替换

2008-04-03 14:24 225 查看
<%
st = "{名字}{称呼}你好,请问你是{公司}的吗?希望{名字}{称呼}能支持我们的调查."
Dim A(2),b(2)
A(0) = "{名字}"
A(1) = "{称呼}"
A(2) = "{公司}"
b(0) = "alex"
b(1) = "先生"
b(2) = "电信"
Function ReplaceTest(patrn, replStr)
Dim regEx'建立变量。
Set regEx = New RegExp '建立正则表达式。
regEx.Pattern = patrn '设置模式。
regEx.IgnoreCase = False '设置是否区分大小写。
ReplaceTest = regEx.Replace(st, replStr) '作替换。
End Function

Function RegExpTest(patrn, strng) '查找字符
Dim regEx, retVal '建立变量。
Set regEx = New RegExp '建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = False ' 设置是否区分大小写。
retVal = regEx.Test(strng) ' 执行搜索测试。
RegExpTest = retVal
End Function

for i = 0 to 2
while RegExpTest(A(i),st)
st = ReplaceTest(A(i), b(i))
wend
next
response.write st
%>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: