replace-regexp

Function

Package: excl

Arguments: string regexp to-string &rest args&key count start end &allow-other-keys

Replace occurrances of regexp in string with to-string. Regular expression groups in regexp can be referenced with \n in to-string. If count is nil or t, replace all occurrances; if a number, replace that number of occurrances. This function accepts all the following match-regexp keywords: newlines-special, case-fold, shortest, start and end, and passes them to match-regexp (used for finding the matches in string). Note that using start and end might be rather inefficient if used repeatedly on a large string, since for each call to replace-regexp, a new string will be created.

Examples:

(replace-regexp "xxx yyy zzz xxx yyy zzz" "xxx" "yyy")
  --> "yyy yyy zzz yyy yyy zzz"


(replace-regexp "xxx yyy zzz xxx yyy zzz xxx" "xxx" "yyy"
		:start 3 :end 20)
 --> "xxx yyy zzz yyy yyy zzz xxx"


(replace-regexp "xxx yyy zzz xxx yyy zzz xxx" "xxx" "yyy"
               :start 3 :end 23)
 --> "xxx yyy zzz yyy yyy zzz xxx"

(replace-regexp "123 yyy zzz 123 yyy zzz 123" "123" "yyy"
                :start 3 :end 27)
  --> "123 yyy zzz yyy yyy zzz yyy"

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.