Function String Replacements Class

StripMatchingEndLine

Strip vFind from vLine only if it appears at the end of vLine, otherwise return the string vLine unchanged.

Signature (Visual Basic / VBA)

Public Function StripMatchingEndLine( _
      ByVal vLine As Variant _
    , ByVal vFind As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    StripMatchingEndLine("This is a test.", "test.") = "This is a "
    StripMatchingEndLine("This is a test.", " is ") = "This is a test.
    StripMatchingEndLine("This is a test.", "") = "This is a test.

Parameters

Parameter Description
vLine The string whose end is to be removed if it matches string vFind. Function returns Null if vLine is Null or cannot be fixed up to a String (Behavior #1).
vFind The string which is to be removed from the end of vLine if present. Function returns Null if vFind is Null or cannot be fixed up to a String (Behavior #2). Function returns vLine unchanged if vFind is an empty string (Behavior #3).
vCompare Specifies the type of comparison used to determine if the strings match (Behavior #4). vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number (Behavior #5).