Function String Replacements Class

StripLastMatch

Find and remove the last occurrence of one string within another. Like the StripFirstMatch function excepts that it searches backwards from the end of the string.

Signature (Visual Basic / VBA)

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

Code Example

    StripLastMatch("This is a test.", "s") = "This is a tet."
    StripLastMatch("This is a test.", "1") = "This is a test."
    StripLastMatch("This is a test.", "") = "This is a test." ' Behavior #3

Parameters

Parameter Description
vLine The string in which the last occurrences of vFind is to be removed. 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 vLine the last time it occurs. 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).