Skip to content
Inverse of rx: convert Emacs string regexps to rx form
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.org
xr-test.el
xr.el

README.org

xr.el

XR converts Emacs regular expressions to the structured rx form, thus being an inverse of rx. It can also find mistakes and questionable constructs inside regexp strings.

It can be useful for:

  • Migrating existing code to rx form
  • Understanding what a regexp string really means
  • Finding errors in regexp strings

It can also parse and find mistakes in skip-sets, the regexp-like arguments to skip-chars-forward and skip-chars-backward.

The xr package can be used interactively or by other code as a library.

Example

(xr-pp "\\`\\(?:[^^]\\|\\^\\(?: \\*\\|\\[\\)\\)")

outputs

(seq bos 
     (or (not (any "^"))
         (seq "^"
              (or " *" "["))))

Installation

From GNU ELPA:

M-x package-install RET xr RET

Interface

Functions parsing regexp strings:

xrconvert regexp to rx
xr-ppconvert regexp to rx and pretty-print
xr-lintfind mistakes in regexp

Functions parsing skip sets:

xr-skip-setconvert skip-set to rx
xr-skip-set-ppconvert skip-set to rx and pretty-print
xr-skip-set-lintfind mistakes in skip-set

Utility:

xr-pp-rx-to-strpretty-print rx expression to string

See also

The relint package uses xr to find regexp mistakes in elisp code.

You can’t perform that action at this time.