Character Matching Using the Period Character matching is one of the most powerful features of regular expressions. They allow the developer to quickly find certain patterns and characters within strings. The . is one of the most important and easiest to use examples of this. The period is a special character with regular expressions that allows the search to find any single character that can exist (except new lines) within an expression. For example, using the following code we can find the value brown out of the string. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strExpression As String = "The quick brown fox jumped over the small fence" Dim regexp As New Regex("b.own") If regexp.IsMatch(strExpression) Then return brown MsgBox("Expression found") Else remove brown and you will get this MsgBox("Expression not found") End If End Sub 6:22:11 PM |
comment [] trackback [] |