输入的字符串进行有规则的清洗
1'----------------------------------------------------
2 '
3 '对输入的字符串进行有规则的清洗。
4 '
5 '对不在[a-zA-Z0-9_]中的字符进行剔出
6 '对 words script|javascript|vbscript|jscript进行删除
7 '
8 '
9 '----------------------------------------------------
10 Public Shared Function CleanStringRegex(ByVal inputText As String) As String
11 Dim options As RegexOptions = RegexOptions.IgnoreCase
12 Return ReplaceRegex(inputText, "[^\\\.!?""',\-\w\s@]", options)
13 End Function 'CleanStringRegex
14
15 '----------------------------------------------------------
16 '使用正则表达式从输入字符串中移出设计字符
17 'regex(regularExpression, options)用修改模式的选项为指定的正则表达式初始化并编译 Regex 类的实例。
18 '----------------------------------------------------
19
20 Private Shared Function ReplaceRegex(ByVal inputText As String, ByVal regularExpression As String, ByVal options As RegexOptions) As String
21 Dim regex As New regex(regularExpression, options)
22 Return regex.Replace(inputText, "")
23 End Function 'ReplaceRegex
2 '
3 '对输入的字符串进行有规则的清洗。
4 '
5 '对不在[a-zA-Z0-9_]中的字符进行剔出
6 '对 words script|javascript|vbscript|jscript进行删除
7 '
8 '
9 '----------------------------------------------------
10 Public Shared Function CleanStringRegex(ByVal inputText As String) As String
11 Dim options As RegexOptions = RegexOptions.IgnoreCase
12 Return ReplaceRegex(inputText, "[^\\\.!?""',\-\w\s@]", options)
13 End Function 'CleanStringRegex
14
15 '----------------------------------------------------------
16 '使用正则表达式从输入字符串中移出设计字符
17 'regex(regularExpression, options)用修改模式的选项为指定的正则表达式初始化并编译 Regex 类的实例。
18 '----------------------------------------------------
19
20 Private Shared Function ReplaceRegex(ByVal inputText As String, ByVal regularExpression As String, ByVal options As RegexOptions) As String
21 Dim regex As New regex(regularExpression, options)
22 Return regex.Replace(inputText, "")
23 End Function 'ReplaceRegex
'