Skip to content

Instantly share code, notes, and snippets.

@spacebat
Forked from nicferrier/*scratch*.el
Last active December 15, 2015 14:19
Show Gist options
  • Save spacebat/5274045 to your computer and use it in GitHub Desktop.
Save spacebat/5274045 to your computer and use it in GitHub Desktop.
I think the [^[] was making the start-of-line/string optional
(let ((regex
(rx
(or bol bos)
(? (not (any "[")))
(group
(>= 2 (and (any "A-Z")(one-or-more (any "a-z")))))))
case-fold-search)
(list
(replace-regexp-in-string regex "{\\1}" "[OneWordOrMore]")
(replace-regexp-in-string regex "{\\1}" "Onewordormore")
(replace-regexp-in-string regex "{\\1}" "[OneWordormore")
(replace-regexp-in-string regex "{\\1}" "OneWordOrMore")
:regex regex))
;; gives ("[OneWordOrMore]" "Onewordormore" "[OneWordormore" "{OneWordOrMore}" :regex "\\(?:^\\|\\`\\)[^[]?\\(\\(?:[A-Z][a-z]+\\)\\{2,\\}\\)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment