GNU ELPA - xr

xr

Description
Convert string regexp to rx notation
Latest
xr-1.11.tar, 2019-Apr-13, 70.0kB
Home page
https://github.com/mattiase/xr
Browse ELPA's repository
CGit or Gitweb

To install this package, run in Emacs:

M-x package-install RET xr RET

Full description

#+TITLE: 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 [[https://elpa.gnu.org/packages/xr.html][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               |

Utility:

| ~xr-pp-rx-to-str~ | pretty-print rx expression to string |

* See also

The [[https://elpa.gnu.org/packages/relint.html][relint]] package uses xr to find regexp mistakes in elisp code.

Old versions

xr-1.9.tar2019-Mar-2170.0kB
xr-1.7.tar2019-Mar-1760.0kB
xr-1.6.tar2019-Mar-1550.0kB
xr-1.5.tar2019-Mar-0250.0kB
xr-1.4.tar2019-Mar-0150.0kB
xr-1.3.tar2019-Feb-2540.0kB
xr-1.2.tar2019-Feb-2040.0kB
xr-1.10.tar2019-Apr-0170.0kB
xr-1.1.tar2019-Feb-1340.0kB
xr-1.0.el2019-Feb-0527.7kB

News

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
  `xr-skip-set-lint'
- 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