diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/syntax-of-regexps.html | |
new repository
Diffstat (limited to 'devdocs/elisp/syntax-of-regexps.html')
| -rw-r--r-- | devdocs/elisp/syntax-of-regexps.html | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/devdocs/elisp/syntax-of-regexps.html b/devdocs/elisp/syntax-of-regexps.html new file mode 100644 index 00000000..81729ee2 --- /dev/null +++ b/devdocs/elisp/syntax-of-regexps.html @@ -0,0 +1,21 @@ + <h4 class="subsection">Syntax of Regular Expressions</h4> <p>Regular expressions have a syntax in which a few characters are special constructs and the rest are <em>ordinary</em>. An ordinary character is a simple regular expression that matches that character and nothing else. The special characters are ‘<samp>.</samp>’, ‘<samp>*</samp>’, ‘<samp>+</samp>’, ‘<samp>?</samp>’, ‘<samp>[</samp>’, ‘<samp>^</samp>’, ‘<samp>$</samp>’, and ‘<samp>\</samp>’; no new special characters will be defined in the future. The character ‘<samp>]</samp>’ is special if it ends a character alternative (see later). The character ‘<samp>-</samp>’ is special inside a character alternative. A ‘<samp>[:</samp>’ and balancing ‘<samp>:]</samp>’ enclose a character class inside a character alternative. Any other character appearing in a regular expression is ordinary, unless a ‘<samp>\</samp>’ precedes it. </p> <p>For example, ‘<samp>f</samp>’ is not a special character, so it is ordinary, and therefore ‘<samp>f</samp>’ is a regular expression that matches the string ‘<samp>f</samp>’ and no other string. (It does <em>not</em> match the string ‘<samp>fg</samp>’, but it does match a <em>part</em> of that string.) Likewise, ‘<samp>o</samp>’ is a regular expression that matches only ‘<samp>o</samp>’. </p> <p>Any two regular expressions <var>a</var> and <var>b</var> can be concatenated. The result is a regular expression that matches a string if <var>a</var> matches some amount of the beginning of that string and <var>b</var> matches the rest of the string. </p> <p>As a simple example, we can concatenate the regular expressions ‘<samp>f</samp>’ and ‘<samp>o</samp>’ to get the regular expression ‘<samp>fo</samp>’, which matches only the string ‘<samp>fo</samp>’. Still trivial. To do something more powerful, you need to use one of the special regular expression constructs. </p> <table class="menu" border="0" cellspacing="0"> <tr> +<td align="left" valign="top">• <a href="regexp-special" accesskey="1">Regexp Special</a> +</td> +<td> </td> +<td align="left" valign="top">Special characters in regular expressions. </td> +</tr> <tr> +<td align="left" valign="top">• <a href="char-classes" accesskey="2">Char Classes</a> +</td> +<td> </td> +<td align="left" valign="top">Character classes used in regular expressions. </td> +</tr> <tr> +<td align="left" valign="top">• <a href="regexp-backslash" accesskey="3">Regexp Backslash</a> +</td> +<td> </td> +<td align="left" valign="top">Backslash-sequences in regular expressions. </td> +</tr> </table><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/Syntax-of-Regexps.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-of-Regexps.html</a> + </p> +</div> |
