blob: cfe91f13e675cf3d526eef6b372dc47b4280ad83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<h4 class="subsubsection">Functions and macros using rx regexps</h4> <dl> <dt id="rx">Macro: <strong>rx</strong> <em>rx-form…</em>
</dt> <dd>
<p>Translate the <var>rx-form</var>s to a string regexp, as if they were the body of a <code>(seq …)</code> form. The <code>rx</code> macro expands to a string constant, or, if <code>literal</code> or <code>regexp</code> forms are used, a Lisp expression that evaluates to a string. Example: </p> <div class="example"> <pre class="example">(rx (+ alpha) "=" (+ digit))
⇒ "[[:alpha:]]+=[[:digit:]]+"
</pre>
</div> </dd>
</dl> <dl> <dt id="rx-to-string">Function: <strong>rx-to-string</strong> <em>rx-expr &optional no-group</em>
</dt> <dd>
<p>Translate <var>rx-expr</var> to a string regexp which is returned. If <var>no-group</var> is absent or nil, bracket the result in a non-capturing group, ‘<samp>\(?:…\)</samp>’, if necessary to ensure that a postfix operator appended to it will apply to the whole expression. Example: </p> <div class="example"> <pre class="example">(rx-to-string '(seq (+ alpha) "=" (+ digit)) t)
⇒ "[[:alpha:]]+=[[:digit:]]+"
</pre>
</div> <p>Arguments to <code>literal</code> and <code>regexp</code> forms in <var>rx-expr</var> must be string literals. </p>
</dd>
</dl> <p>The <code>pcase</code> macro can use <code>rx</code> expressions as patterns directly; see <a href="pcase-macro#rx-in-pcase">rx in pcase</a>. </p> <p>For mechanisms to add user-defined extensions to the <code>rx</code> notation, see <a href="extending-rx">Extending Rx</a>. </p><div class="_attribution">
<p class="_attribution-p">
Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
<a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Rx-Functions.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Rx-Functions.html</a>
</p>
</div>
|