Created
September 18, 2020 10:35
-
-
Save chaitanyagupta/058f171e7f927554c393674a36f58e0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun search-and-replace-all (old new string) | |
(loop | |
with start = 0 | |
for pos = (search old string :start2 start) | |
while pos | |
do (setf string (concatenate 'string | |
(subseq string 0 pos) | |
new | |
(subseq string (+ pos (length old)))) | |
start (+ pos (length new)))) | |
string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment