Convert string regexp to rx notation
xr-1.19.tar, 2020-May-03, 120 KiB
Home page
Browse ELPA's repository
CGit or Gitweb

To install this package, run in Emacs:

M-x package-install RET xr RET

Full description

                xr -- Emacs regexp parser and analyser

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 "\\`\\(?:[^^]\\|\\^\\(?: \\*\\|\\[\\)\\)")


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

* Installation

  From GNU ELPA (

    M-x package-install RET xr RET

* Interface

  Functions parsing regexp strings:
   xr       --  convert regexp to rx
   xr-pp    --  convert regexp to rx and pretty-print
   xr-lint  --  find mistakes in regexp
  Functions parsing skip sets:
   xr-skip-set       --  convert skip-set to rx
   xr-skip-set-pp    --  convert skip-set to rx and pretty-print
   xr-skip-set-lint  --  find mistakes in skip-set
   xr-pp-rx-to-str  --  pretty-print rx expression to string
* See also

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

  The lex package (, a lexical
  analyser generator, provides the lex-parse-re function which
  translates regexps to rx, 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, can also be used
  for translating regexps to rx. However, xr is more accurate for this

Old versions

xr-1.18.tar2020-Mar-09 110 KiB
xr-1.17.tar2020-Mar-05 110 KiB
xr-1.16.tar2020-Mar-01 110 KiB
xr-1.15.tar2020-Jan-3190.0 KiB
xr-1.14.tar2020-Jan-2390.0 KiB
xr-1.13.tar2019-Aug-0490.0 KiB
xr-1.12.tar2019-May-2680.0 KiB
xr-1.11.tar2019-Apr-1370.0 KiB
xr-1.10.tar2019-Apr-0170.0 KiB
xr-1.9.tar2019-Mar-2170.0 KiB
xr-1.7.tar2019-Mar-1760.0 KiB
xr-1.6.tar2019-Mar-1550.0 KiB
xr-1.5.tar2019-Mar-0250.0 KiB
xr-1.4.tar2019-Mar-0150.0 KiB
xr-1.3.tar2019-Feb-2540.0 KiB
xr-1.2.tar2019-Feb-2040.0 KiB
xr-1.1.tar2019-Feb-1340.0 KiB
xr-1.0.el2019-Feb-0527.7 KiB


Version 1.19:
- Added filename-specific checks; new PURPOSE argument to `xr-lint'
- Warn about wrapped subsumption, like \(A*C[AB]*\)+
- Improved scope and accuracy of all subsumption checks
- Warn about anchors in conflict with other expressions, like \(A$\)B
Version 1.18:
- Fix test broken in Emacs 26
Version 1.17:
- Performance improvements
Version 1.16:
- Translate [^\n] into nonl
- Better character class subset/superset analysis
- More accurate repetition subsumption check
- Use text quoting for messages
Version 1.15:
- Warn about subsuming repetitions in sequence, like [AB]+A*
Version 1.14:
- Warn about repetition of grouped repetition
Version 1.13:
- More robust pretty-printing, especially for characters
- Generate (category CHAR) for unknown categories
Version 1.12:
- Warn about branch subsumption, like [AB]\|A
Version 1.11:
- Warn about repetition of empty-matching expressions
- Detect `-' not first or last in char alternatives or skip-sets
- Stronger ad-hoc [...] check in skip-sets
Version 1.10:
- Warn about [[:class:]] in skip-sets
- Warn about two-character ranges like [*-+] in regexps
Version 1.9:
- Don't complain about [z-a] and [^z-a] specifically
- Improved skip set checks
Version 1.8:
- Improved skip set checks
Version 1.7:
- Parse skip-sets, adding `xr-skip-set', `xr-skip-set-pp' and
- Ad-hoc check for misplaced `]' in regexps
Version 1.6:
- Detect duplicated branches like A\|A
Version 1.5:
- Add dialect option to `xr' and `xr-pp'
- Negative empty sets, [^z-a], now become `anything'
Version 1.4:
- Detect overlap in character alternatives
Version 1.3:
- Improved xr-lint warnings
Version 1.2:
- `xr-lint' added