Created
June 2, 2016 19:31
-
-
Save fstamour/899746a0a0b7834885e96232b1f20d31 to your computer and use it in GitHub Desktop.
Small emacs lisp function "If STRING starts with PREFIX, replace the PREFIX by NEW-PREFIX. Else, returns NIL."
This file contains hidden or 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 replace-prefix-if-present (string prefix new-prefix) | |
"If STRING starts with PREFIX, replace the PREFIX by NEW-PREFIX. | |
Else, returns NIL." | |
(if (string-prefix-p prefix string) | |
(concat new-prefix (substring string (length prefix))) | |
nil)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment