你好如何在vb.net中使用正则表达式确定标点字符?

时间:2014-04-11 12:54:16

标签: regex vb.net

我仍在使用vb.net学习dekstop编程 现在我学习正则表达式模式,我可以使用正则表达式模式确定大写字母" [A-Z]"和更多。但如何使用正则表达式模式确定标点字符?

标点字符: !"#\ $%&安培;'()* +, - /:;?< => \ @ [\] \ ^ _`{\ |}〜

   Public Sub UniqueKeyCodeStrengthCalculator()
        If Regex.IsMatch(keycode, "[A-Z]") Then
            MsgBox("Contain Capital Letter")
        ElseIf Regex.IsMatch(keycode, "\d") Then
            MsgBox("Contain number")
        ElseIf Regex.IsMatch(keycode, "[a-z]") Then
            MsgBox("Contain Non-capital Letter")
        End If
    End Sub

谢谢你。

1 个答案:

答案 0 :(得分:1)

只需使用此正则表达式:

[\W_0-9]

\W会检查a-z A-Z_以外的所有字符。

上述正则表达式将起作用。