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

Replace Like String Function
String Replacements Class

Public Function ReplaceLikeString( _
      ByVal vLine As Variant _
    , ByVal vLike As Variant _
    , Optional ByVal vReplace As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Perform string replacement.
Replace all non-overlapping occurrences of LIKE pattern vLike in vLine with vReplace.

Examples:
    ReplaceLikeString("This is a test.", " ", "-") = "This-is-a-test."
    ReplaceLikeString("This is a test.", "?s", "XX") = "ThXX XX a tXXt."
    ReplaceLikeString("This is a test.", "", "23") = "This is a test." ' Behavior #3
    ReplaceLikeString("This is a test.", " ", "") = "Thisisatest." ' Behavior #5
    ReplaceLikeString("This is a test.", "?s", "xss") = "Thixss ixss a texsst." ' Behavior #6
See also:
    ReplaceString Function
vLine: The string in which all occurrences of LIKE pattern vLike are to be replaced with vReplace. Function returns Null if vLine is Null or cannot be fixed up to a String (Behavior #1).

vLike: The LIKE pattern string which is to be replaced with vReplace wherever it appears within string vLine. Function returns Null if vLike is Null or cannot be fixed up to a String (Behavior #2). Function returns vLine unchanged if vLike is an empty string (Behavior #3).

vReplace: The string which is to replace all occurrences of LIKE pattern vLike within string vLine. vReplace defaults to an empty string if it is missing or Null or cannot be fixed up to a String (Behavior #4). vReplace can be an empty string in which case all occurrences of vFind are removed from the string vLine (Behavior #5).

Note: This function works correctly with vReplace strings that contain the vLike pattern string. For example, Chr$(10) can be replaced by Chr$(10)+Chr$(13) without the function getting stuck in an infinite loop (Behavior #6).

vCompare: Specifies the type of comparison used to determine if strings match (Behavior #7). vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number (Behavior #8).

v2.0 Addition: This function is new to this version of Entisoft Tools.

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