Created
August 15, 2011 23:40
-
-
Save legumbre/1148156 to your computer and use it in GitHub Desktop.
longest common suffix of two strings
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
;; awful hack, get the common suffix from two strings using regexp-quote | |
(let* ((a "foo/bar") | |
(b "baz/bar") | |
(ro (regexp-opt (list a b)))) | |
(string-match "\\\\)\\(.*?\\)\\\\)$" ro) | |
(match-string 1 ro)) | |
;; "/bar" | |
;; what trickery be this?! | |
;; (regexp-opt '("foooooooobaz" "barrrrrrrbaz")) ;; "\\(?:\\(?:barrrrrrr\\|foooooooo\\)baz\\)" | |
;; so we match the last \\)baz\\)$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment