GNU ELPA - xr

xr

Description
Convert string regexp to rx notation
Latest
xr-1.2.tar, 2019-Feb-20, 40.0kB
Home page
http://elpa.gnu.org/packages/xr.html
Browse repository
CGit or Gitweb

To install this package, run in Emacs:

M-x package-install RET xr RET

Full description

This is an inverse companion to the rx package for translating
regexps in string form to the rx notation.  Its chief uses are:

- Migrating existing code to rx form, for better readability and
  maintainability
- Understanding complex regexp strings and finding errors in them
  
Please refer to `rx' for more information about the notation.

The exported functions are:

 `xr'              - returns the converted rx expression
 `xr-pp'           - pretty-prints the converted rx expression
 `xr-lint'         - finds deprecated syntax in a regexp string
 `xr-pp-rx-to-str' - pretty-prints an rx expression to a string

Suggested use is from an interactive elisp buffer.

Example (regexp found in compile.el):

  (xr-pp "\\`\\(?:[^^]\\|\\^\\(?: \\*\\|\\[\\)\\)")
=>
  (seq bos
       (or
        (not (any "^"))
        (seq "^"
             (or " *" "["))))

The rx notation admits many synonyms; the xr functions mostly
prefer brief variants, such as `seq' to `sequence' and `nonl' to
`not-newline'.  The user is encouraged to edit the result for
maximum readability, consistency and personal preference when
replacing existing regexps in elisp code.

Related work:

The `lex' package, a lexical analyser generator, provides the
`lex-parse-re' function which performs a similar task, but does not
attempt to handle all the edge cases of Elisp's regexp syntax or
pretty-print the result.

The `pcre2el' package, a regexp syntax converter and interactive regexp
explainer, could also be used for the same tasks. `xr' is narrower in
scope but more accurate for the purpose of parsing Emacs regexps and
printing the results in rx form.

Old versions

xr-1.1.tar2019-Feb-1340.0kB
xr-1.0.el2019-Feb-0527.7kB