aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2014-12-26 17:22:03 -0500
committerSean Allred <code@seanallred.com>2014-12-26 17:22:03 -0500
commitd732176007abdcc3395f7188dc918981d9ff2801 (patch)
treeedb3b42ee26c3502adf9ea1eb609d8f5d917593b
parent60e483c5f6bfa5ea897f3bc6f85f402b09f63d9e (diff)
`rx'-ify regular expression
-rw-r--r--sx.el10
1 files changed, 9 insertions, 1 deletions
diff --git a/sx.el b/sx.el
index 7f6b901..19c5f12 100644
--- a/sx.el
+++ b/sx.el
@@ -294,7 +294,15 @@ DATA can also be the link itself."
(cdr (assoc 'link data)))))
(when (stringp link)
(replace-regexp-in-string
- "^https?://\\(?:\\(?1:[^/]+\\)\\.stackexchange\\|\\(?2:[^/]+\\)\\)\\.[^.]+/.*$"
+ (rx line-start "http" (optional "s") "://"
+ (or
+ (sequence
+ (group-n 1 (+ (not (any "/"))))
+ ".stackexchange")
+ (group-n 2 (+ (not (any "/")))))
+ "." (+ (not (any ".")))
+ "/" (* any)
+ line-end)
"\\1\\2" link))))
(defun sx--ensure-site (data)