Chilkat HOME Android™ ASP Visual Basic VB.NET C# iOS (IPhone) Objective-C C++ C Unicode C++ Unicode C MFC Delphi DLL Delphi ActiveX FoxPro Java Perl PHP Extension PHP ActiveX Python PowerShell Ruby SQL Server VBScript
String Pattern MatchingThis 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
|
© 2000-2013 Chilkat Software, Inc. All Rights Reserved.