std-strchg, std-string-subst


Synopsis

(std-strchg <str> <old> <new>)

(std-string-subst <new> <old> <str>) ; same but reverse argument order

Description

Both are a simple string search and replace function. The argument ordering in STD-STRCHG matches the <what> <how> <new> system used in objects, STD-STRING-SUBST has the same order as subst.

It works case-sensitively and does not expand regular expresssions. If old is an empty string than the whole string is replaced by new.

STD-STRCHG replaces ALL occurances, STD-STRING-SUBST only the FIRST occurance of the substring in the string.

Note:

This is because the (in R14 undocumented) Visual LISP function VL-STRING-SUBST replaces only the first instance of the found substring.

Examples

(std-strchg "test" "s" "S")  => "teSt"
(std-strchg "test" "" "new")  => "new"
(std-string-subst "new" "old" "old-test-old") 	=> "new-test-old"

Arguments

str: a string.

old: a string.

new: a string.

Return Value

A string.

Side Effects

None.

Module

(std-require 'STDSTR)

Defined in STDSTR