欢迎光临
我们一直在努力

如何使replace方法不区分大小写?

建站超值云服务器,限时71元/月

被替换的文本的实际模式是通过 regexp 对象的 pattern 属性设置的。

replace 方法返回 string1 的副本,其中的 regexp.pattern 文本已经被替换为 string2。如果没有找到匹配的文本,将

返回原来的 string1 的副本。

下面的例子说明了 replace 方法的用法。

function replacetest(patrn, replstr)

dim regex, str1 建立变量。

str1 = "the quick brown fox jumped over the lazy dog."

set regex = new regexp 建立正则表达式。

regex.pattern = patrn 设置模式。

regex.ignorecase = true 设置是否区分大小写。

replacetest = regex.replace(str1, replstr) 作替换。

end function

msgbox(replacetest("fox", "cat")) 将 fox 替换为 cat。

;另外,replace 方法在模式中替换 subexpressions 。 下面对以前示例中函数的调用,替换了原字符串中的所有字

对:

msgbox(replacetext("(\s+)(\s+)(\s+)", "$3$2$1")) 交换词对.

要求的脚本语言在5.0以上

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何使replace方法不区分大小写?
分享到: 更多 (0)