Skip to content

Instantly share code, notes, and snippets.

@html
Created November 16, 2012 09:18
Show Gist options
  • Save html/4085786 to your computer and use it in GitHub Desktop.
Save html/4085786 to your computer and use it in GitHub Desktop.
Normalize newlines for Common Lisp
(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