Function: rx-to-string

rx-to-string is an autoloaded and byte-compiled function defined in rx.el.gz.

Signature

(rx-to-string FORM &optional NO-GROUP)

Documentation

Translate FORM from rx sexp syntax into a string regexp.

The arguments to literal and regexp forms inside FORM must be constant strings. If NO-GROUP is non-nil, don't bracket the result in a non-capturing group.

For extending the rx notation in FORM, use rx-define or rx-let-eval.

Other relevant functions are documented in the regexp group.

View in manual

Probably introduced at or before Emacs version 21.1.

Shortdoc

;; regexp
(rx-to-string '(| "foo" "bar"))
    => "\\(?:bar\\|foo\\)"

Aliases

rx-submatch-n (obsolete since 27.1)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/rx.el.gz
;;;###autoload
(defun rx-to-string (form &optional no-group)
  "Translate FORM from `rx' sexp syntax into a string regexp.
The arguments to `literal' and `regexp' forms inside FORM must be
constant strings.
If NO-GROUP is non-nil, don't bracket the result in a non-capturing
group.

For extending the `rx' notation in FORM, use `rx-define' or `rx-let-eval'."
  (declare (important-return-value t))
  (let* ((item (rx--translate form))
         (exprs (if no-group
                    (car item)
                  (rx--atomic-regexp item))))
    (apply #'concat exprs)))