To install this package, run in Emacs:
M-x package-install RET xr RET
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.