Signature (Visual Basic / VBA)
Public Function GrepToLike( _
ByVal vPattern As Variant _
) As Variant
Code Example
GrepToLike("Washington") = "*Washington*"
GrepToLike("^Washington") = "Washington*"
GrepToLike("^Washington$") = "Washington"
GrepToLike("\^Washington\$") = "*^Washington$*"
GrepToLike("\\Washington\$") = "*\Washington$*"
GrepToLike("\\Washington\\") = "*\Washington\\*"
GrepToLike("Wash\ing\ton") = "*Wash\ing\ton*"
Parameters
| Parameter | Description |
|---|---|
| vPattern | The UNIX-like regular expression which is to be converted into a corresponding LIKE operator pattern. Function returns Null if vPattern is Null or cannot be fixed up to a String. Ignore leading backslash character and interpret next character literally. When caret found at beginning of string: anchor to beginning of line. Ignore trailing backslash dollar-sign characters, interpreting the dollar sign literally. When dollar-sign found at end of string: anchor to end of line. |
Notes & Version History
| Summary | Make minor modifications to the patterns recognized by the Visual Basic LIKE operator to make them more like the regular expressions as defined under UNIX. Patterns are normally changed so that they are not anchored to the beginning and end of the string to be searched. A leading caret anchors the match to the beginning of he search string, and a trailing dollar sign anchors the match to the end of the search string. Either of these interpretations can be overridden by preceding the characters with a backslash. In addition, leading and/or trailing backslashes must also be preceded by a backslash. |