Substitutes one string for another, within a string
(vl-string-subst new-str pattern string [start-pos])
Arguments
The string to be substituted for pattern.
A string containing the pattern to be replaced.
The string to be searched for pattern.
An integer identifying the starting position of the search; 0 if omitted.
vl-string-subst substitutes only the first occurrence it finds of the string.
Note that the search is case-sensitive, and thatReturn Values
The value of string after any substitutions have been made.
Examples
Replace the string “Ben” with “Obi-wan”:
_$ (vl-string-subst "Obi-wan" "Ben" "Ben Kenobi")
"Obi-wan Kenobi"
Replace “Ben” with “Obi-wan”:
_$ (vl-string-subst "Obi-wan" "Ben" "ben Kenobi")
"ben Kenobi"
vl-string-subst did not find a match for “Ben”; the “ben” in the string that was searched begins with a lowercase “b”.
Nothing was substituted becauseReplace “Ben” with “Obi-wan”:
_$ (vl-string-subst "Obi-wan" "Ben" "Ben Kenobi Ben")
"Obi-wan Kenobi Ben"
vl-string-subst replaces only the first occurrence.
Note that there are two occurrences of “Ben” in the string that was searched, butReplace “Ben” with “Obi-wan,” but start the search at the fourth character in the string:
_$ (vl-string-subst "Obi-wan" "Ben" "Ben \"Ben\" Kenobi" 3)
"Ben \"Obi-wan\" Kenobi"
vl-string-subst was instructed to begin searching at the fourth character, it found and replaced the second occurrence, not the first.
There are two occurrences of “Ben” in the string that was searched, but because