Skip to content

Instantly share code, notes, and snippets.

@v2e4lisp
Created July 24, 2013 14:34
Show Gist options
  • Select an option

  • Save v2e4lisp/6071130 to your computer and use it in GitHub Desktop.

Select an option

Save v2e4lisp/6071130 to your computer and use it in GitHub Desktop.
(defvar <- "\\(")
(defvar -> "\\)")
(defalias '@ 'regexp-quote)
(defun re/start-of-line (&optional next)
(concat "^" next))
(defun re/end-of-line (&optional next)
(concat "$" next))
(defun re/anything (&optional next)
(concat <- ".*" -> next))
(defun re/anything-but (value &optional next)
(concat "[^" (@ value) "]*"))
(defun re/maybe (value &optional next)
(concat <- (@ value) -> "?"))
(defun re/find (value &optional next)
(concat <- (@ value) -> next))
(defun re/any (value &optional next)
(concat <- "[" (@ value) "]" ->))
(defalias 're/any-of 're/any)
(defun re/line-break (&optional next)
(concat <- "\r?\n" -> next))
(defun re/range (&rest args)
(let ((1st (car args))
(2nd (cadr args)))
(if (and 1st 2nd)
(concat 1st "-" 2nd (apply 're/range (cddr args)))
1st)))
(re-search-backward (re/line-break))
(cl-loop for x y in (1,2,3,4) collect (x, y))
(start_of_line)
\\[\\^(d)]
(re-search-backward (regexp-quote "[^\(d\)]"))
(search-backward (regexp-quote "defun") nil nil 2)
(goto-char (re-search-forward (anything)))
(goto-char (re-search-forward (anything-but "(abc^"))) ;; hello world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment