Syntax |
expression Like pattern |
||
Description |
Compares two strings and returns TRUE if the expression matches the given pattern; returns FALSE otherwise. |
||
Comments |
Case sensitivity is controlled by the Option Compare setting. The pattern expression can contain special characters that allow more flexible matching: |
||
|
Character |
Evaluates to |
|
|
? |
Matches a single character. |
|
|
* |
Matches one or more characters. |
|
|
# |
Matches any digit. |
|
|
[range] |
Matches if the character in question is within the specified range. |
|
|
[!range] |
Matches if the character in question is not within the specified range. |
|
|
A range specifies a grouping of characters. To specify a match of any of a group of characters, use the syntax [ABCDE]. To specify a range of characters, use the syntax [A-Z]. Special characters must appear within brackets, such as []*?#. If expression or pattern is not a string, then both expression and pattern are converted to String variants and compared, returning a Boolean variant. If either variant is Null, then Null is returned. The following table shows some examples: |
||
|
expression |
TRUE If pattern Is |
FALSE If pattern is Is |
|
"EBW" |
"E*W", "E*" |
"E*B" |
|
"BasicScript" |
"B*[r-t]icScript" |
"B[r-t]ic" |
|
"Version" |
"V[e]?s*n" |
"V[r]?s*N" |
|
"2.0" |
"#.#", "#?#" |
"###", "#?[!0-9]" |
|
"[ABC]" |
"[[]*]" |
"[ABC]", "[*]" |
Example |
This example demonstrates various uses of the Like function. Sub Main() |
||
See Also |
Operator Precedence (topic); Is (operator); Option Compare (statement). |
L |