Created
November 16, 2012 09:18
-
-
Save html/4085786 to your computer and use it in GitHub Desktop.
Normalize newlines for Common Lisp
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 normalize-newlines (string) | |
(ppcre:regex-replace-all (format nil "~C(\n)?" #\return) string "\n")) | |
(assert (string= (normalize-newlines "as\ndf") "as\ndf")) | |
(assert (string= (normalize-newlines (format nil "as~C\ndf" #\return)) "as\ndf")) | |
(assert (string= (normalize-newlines (format nil "as~Cdf" #\return)) "as\ndf")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment