Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
String Pattern Matching This example explains how to do string pattern matching in Visual Basic. ' The Like operator pays attention to the current Option Compare setting.
' Setting it to text makes the pattern matching case-insensitive.
Option Compare Text
' Use Option Compare Binary for case-sensitive string pattern matching.
' Option Compare Binary
' The Like string operator provides string pattern matching in Visual Basic.
' * matches zero or more of any character.
' ? matches any single character.
' # matches any single digit.
' Match ranges of characters by enclosing the range in brackets:
' [A-C] Matches any of A, B, or C
' [ABC] Same as [A-C]
' Match characters not in a range by using !
' [!A-Z] Any character not including A-Z
Dim s As String
s = "Chilkat Software 1234 ABCD"
If s Like "*Software*" Then
Print "Contains Software"
End If
If s Like "[!0-9]??*" Then
' Match any three characters such that the first cannot be a digit.
Print "Matches!"
End If
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.