of matching @var{regexp} against a substring of @var{string}.
@end defun
-@defun string-replace fromstring tostring instring
-This function replaces all occurrences of @var{fromstring} with
-@var{tostring} in @var{instring} and returns the result. It may
+@defun string-replace from-string to-string in-string
+This function replaces all occurrences of @var{from-string} with
+@var{to-string} in @var{in-string} and returns the result. It may
return one of its arguments unchanged, a constant string or a new
string. Case is significant, and text properties are ignored.
@end defun
(defalias 'tramp-compat-string-replace
(if (fboundp 'string-replace)
#'string-replace
- (lambda (fromstring tostring instring)
+ (lambda (from-string to-string in-string)
(let ((case-fold-search nil))
(replace-regexp-in-string
- (regexp-quote fromstring) tostring instring t t)))))
+ (regexp-quote from-string) to-string in-string t t)))))
;; Function `string-search' is new in Emacs 28.1.
(defalias 'tramp-compat-string-search
(aset newstr i tochar)))
newstr))
-(defun string-replace (fromstring tostring instring)
- "Replace FROMSTRING with TOSTRING in INSTRING each time it occurs."
+(defun string-replace (from-string to-string in-string)
+ "Replace FROM-STRING with TO-STRING in IN-STRING each time it occurs."
(declare (pure t) (side-effect-free t))
- (when (equal fromstring "")
+ (when (equal from-string "")
(signal 'wrong-length-argument '(0)))
(let ((start 0)
(result nil)
pos)
- (while (setq pos (string-search fromstring instring start))
+ (while (setq pos (string-search from-string in-string start))
(unless (= start pos)
- (push (substring instring start pos) result))
- (push tostring result)
- (setq start (+ pos (length fromstring))))
+ (push (substring in-string start pos) result))
+ (push to-string result)
+ (setq start (+ pos (length from-string))))
(if (null result)
;; No replacements were done, so just return the original string.
- instring
+ in-string
;; Get any remaining bit.
- (unless (= start (length instring))
- (push (substring instring start) result))
+ (unless (= start (length in-string))
+ (push (substring in-string start) result))
(apply #'concat (nreverse result)))))
(defun replace-regexp-in-string (regexp rep string &optional