<-- Previous || Up || Next -->

Egrep Or Strings To Regex Pattern Function
String Extras Class

Public Function EgrepOrStringsToRegexPattern( _
      ByVal vOrStrings As Variant _
    , Optional ByVal vSeparator As Variant _
    ) As Variant

"UNIX egrep Or Strings To Regular Expression Pattern"
Create a Find pattern that will search for any of several words using a single Find command within Microsoft products like Visual Basic, Access, etc.
Convert a UNIX "egrep" (extended global regular expression) like "or" string expression into a pattern recognized by the Microsoft's Find command.

Examples:
    EgrepOrStringsToRegexPattern("If|On") = "[IO][fn]"
    EgrepOrStringsToRegexPattern("Unique|Dups") = "[UD][nu][ip][qs]"
See also:
    CharactersToSQLInExpression Function
    Like Operator (Visual Basic)
    egrep Program (UNIX)
This function will create an expression that, with Pattern Matching enabled, can be used to locate occurrences of more than one word using a single Find command within Microsoft products like Visual Basic, Access, etc. Function interprets a string "Unique|Dups" as a pattern that will match text containing either "Unique" or "Dups".
Note: Function creates a string expression which uses character classes to find the words. Because of this imperfect translation of the "or" expression, the search may find some matches which do not represent any of the original words. For example, a vOrStrings of "If|On" would translate to "[IO][fn]", and when used with the Find command, that pattern would find all occurrences of the string "If", "In", "On", and "Of".

vOrStrings: String containing the list or words (or phrases) each separated by the string vSeparator. Function returns Null if vOrStrings is Null or cannot be fixed up to a String.

vSeparator: The string which separates the words (or phrases) within string vOrStrings. vSeparator defaults to the vertical-bar character (|) if it is missing or Null or cannot be fixed up to a String.

Note: Function uses Binary comparisons to locate the separator string vSeparator within the string vOrStrings.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.