vb.net/asp.net自定义表达式中的正则表达式验证器

时间:2011-04-19 15:56:51

标签: asp.net vb.net

我想确保使用自定义表达式验证器,我可以使用[^“'尝试不使用'或',但每当我放普通字母时它也不起作用。

1 个答案:

答案 0 :(得分:0)

我会做一个正则表达式替换匹配['“]并将其替换为空(即”“”)。

在VB.NET中,代码如下:

dim strTest as string = "This "is" a test'"
dim regex as regex = new regex("[" & chr(34) & "']", regexoptions.ingorePatternWhitespace)
msgbox(regex.Replace(strTest, ""))

输出 这是一个测试