Function String Replacements Class

StripMatchingEndLineFast

Strip vFind from vLine only if it appears at the end of vLine, otherwise return the string vLine unchanged. Faster version of the StripMatchingEndLine function which uses restrictive argument types to avoid argument fix-up code.

Signature (Visual Basic / VBA)

Public Function StripMatchingEndLineFast( _
      ByRef vLine As String _
    , ByRef vFind As String _
    , ByRef vCompare As VbCompareMethod _
    ) As String

Code Example

    StripMatchingEndLineFast("This is a test.", "test.", vbTextCompare) = "This is a "
    StripMatchingEndLineFast("This is a test.", " is ", vbTextCompare) = "This is a test.
    StripMatchingEndLineFast("This is a test.", "", vbTextCompare) = "This is a test.

Parameters

Parameter Description
vLine The string whose end is to be removed if it matches string vFind.
vFind The string which is to be removed from the end of vLine if present. Function returns vLine unchanged if vFind is an empty string (Behavior #1).
vCompare Specifies the type of comparison used to determine if the strings match (Behavior #2).