Substitutes one string for another, within a string
Supported Platforms: Windows and Mac OS
(vl-string-subst new-str pattern str [start-pos])
Type: String
The textual value to be substituted for pattern.
Type: String
The textual value containing the pattern to be replaced.
Type: String
The textual value to be searched for pattern.
Type: Integer
A numeric value identifying the starting position of the search; 0 if omitted.
Type: String
The value of str after any substitutions have been made.
Note that the search is case-sensitive, and that vl-string-subst substitutes only the first occurrence it finds of the string.
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"
Nothing was substituted because vl-string-subst did not find a match for “Ben”; the “ben” in the string that was searched begins with a lowercase “b”.
Replace “Ben” with “Obi-wan”:
(vl-string-subst "Obi-wan" "Ben" "Ben Kenobi Ben") "Obi-wan Kenobi Ben"
Note that there are two occurrences of “Ben” in the string that was searched, but vl-string-subst replaces only the first occurrence.
Replace “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"
There are two occurrences of “Ben” in the string that was searched, but because vl-string-subst was instructed to begin searching at the fourth character, it found and replaced the second occurrence, not the first.