Function String Searches Class

StringsBetweenStringsFast

Return the strings between the all occurrences of vRight and vLeft. If more than one match is found, the matches are separated by vSeparator. Return a blank string if there is no match of vLeft followed by vRight. Faster version of the StringaBetweenStrings function which uses restrictive argument types to avoid argument fix-up code.

Signature (Visual Basic / VBA)

Public Function StringsBetweenStringsFast( _
      ByRef vSearch As String _
    , ByRef vLeft As String _
    , ByRef vRight As String _
    , ByRef vSeparator As String _
    , ByVal vCompare As VbCompareMethod _
    ) As String

Code Example

    StringsBetweenStringsFast("Forms![Menu]![Close]", "[", "]", "-", vbBinaryCompare) = "Menu-Close"
    StringsBetweenStringsFast("Forms![Menu]![Close]", "(", ")", "-", vbBinaryCompare) = "" ' #2.
    StringsBetweenStringsFast("Larry 'Bud' Melman", "'", "'", "-", vbBinaryCompare) = "Bud"

Parameters

Parameter Description
vSearch The string which is to be searched for non-overlapping appearances of vLeft followed by vRight.
vLeft The string which delimits the left side of each sub-string to be returned.
vRight The string which delimits the right side of each sub-string to be returned.
vSeparator The string which will be used to separate the matching strings within the result.
vCompare Specifies the type of comparison used to determine if strings match. Function returns an empty string if both vLeft or vRight is an empty string. If vLeft is an empty string and vRight is not, the function returns the sub-string of vSearch between the beginning of the string and the first occurrence of vRight. If vRight is an empty string and vLeft is not, the function returns the sub-string of vSearch between the first occurrence of vLeft and the end of the string. Function returns an empty string if vLeft does not appear within vSearch followed by vRight.