Skip to content

Instantly share code, notes, and snippets.

@codeforkjeff
Created April 12, 2013 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforkjeff/5368935 to your computer and use it in GitHub Desktop.
Save codeforkjeff/5368935 to your computer and use it in GitHub Desktop.
(defun mask-ssn (num)
(save-match-data
(concat "XXX-XX-" (nth 2 (split-string num "-")))))
(replace-regexp-in-string "[0-9]\\{3\\}-[0-9]\\{2\\}-[0-9]\\{4\\}"
'mask-ssn
"Here's a number: 999-22-1111. Here's another: 222-11-9999.")
;; evaluates to "Here's a number: XXX-XX-1111. Here's another: XXX-XX-9999."
;; Hooray!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment