products/Sources/formale Sprachen/Isabelle/Tools/jEdit/dist/doc/users-guide image not shown  

Quellcode-Bibliothek

© Kompilation durch diese Firma

[Weder Korrektheit noch Funktionsfähigkeit der Software werden zugesichert.]

Datei: regexps.html   Sprache: HTML

Original von: Isabelle©

 products/Sources/formale Sprachen/Isabelle/Tools/jEdit/dist/doc/users-guide/regexps.html


<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Appendix E. Regular Expressions</title><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="index.html" title="jEdit 5.6 User's Guide"><link rel="up" href="using-jedit-part.html" title="Part I. Using jEdit"><link rel="prev" href="globs.html" title="Appendix D. Glob Patterns"><link rel="next" href="macro-index.html" title="Appendix F. Macros Included With jEdit"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix E. Regular Expressions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="globs.html">Prev</a> </td><th width="60%" align="center">Part I. Using jEdit</th><td width="20%" align="right"> <a accesskey="n" href="macro-index.html">Next</a></td></tr></table><hr></div><div class="appendix"><div class="titlepage"><div><div><h2 class="title"><a name="regexps"></a>Appendix E. Regular Expressions</h2></div></div></div><p>jEdit uses regular expressions from <a class="ulink" href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html" target="_top">java.util.regex.Pattern</a>
    to implement inexact search and replace. Click there to see a complete
    reference guide to all supported meta-characters.</p><p>A regular expression consists of a string where some characters are
    given special meaning with regard to pattern matching.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Inside XML files</h3><p>Inside XML files (such as jEdit mode files), it is important that
        you escape XML special characters, such as &, <, >, etc. You
        can use the XML plugin's "characters to entities" to perform this
        mapping.</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Inside Java / beanshell / properties files</h3><p>Java strings are always parsed by java before they are processed
        by the regular expression engine, so you must make sure that backslashes
        are escaped by an extra backslash (<code class="literal">\\</code>)</p></div><p>Within a regular expression, the following characters have special
    meaning:</p><h2><a name="d0e8102"></a>Positional Operators</h2><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="literal">^</code> matches at the beginning of a line</p></li><li class="listitem"><p><code class="literal">$</code> matches at the end of a line</p></li><li class="listitem"><p><code class="literal">\b</code> matches at a word boundary</p></li><li class="listitem"><p><code class="literal">\B</code> matches at a non-word break</p></li><li class="listitem"><p><code class="literal">\A</code> The beginning of the input</p></li><li class="listitem"><p><code class="literal">\G</code> The end of the previous match</p></li><li class="listitem"><p><code class="literal">\Z</code> The end of the input but for the final terminator, if any</p></li><li class="listitem"><p><code class="literal">\z</code> The end of the input</p></li></ul></div><h2><a name="d0e8145"></a>One-Character Operators</h2><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="literal">.</code> matches any single character (may or may not match line terminators)</p></li><li class="listitem"><p><code class="literal">\d</code> matches any decimal digit (<code class="literal">[0-9]</code>)</p></li><li class="listitem"><p><code class="literal">\D</code> matches any non-digit (<code class="literal">[^0-9]</code>)</p></li><li class="listitem"><p><code class="literal">\n</code> matches the newline character (<code class="literal">\u000A</code>)</p></li><li class="listitem"><p><code class="literal">\s</code> matches any whitespace character (<code class="literal">[ \t\n\x0B\f\r]</code>)</p></li><li class="listitem"><p><code class="literal">\x<em class="replaceable"><code>hh</code></em></code> matches hexadecimal character code <code class="literal">0xhh</code></p></li><li class="listitem"><p><code class="literal">\S</code> matches any non-whitespace character (<code class="literal">[^\s]</code>)</p></li><li class="listitem"><p><code class="literal">\t</code> matches a horizontal tab character (<code class="literal">\u0009</code>)</p></li><li class="listitem"><p><code class="literal">\w</code> matches any word character (<code class="literal">[a-zA-Z_0-9]</code>)</p></li><li class="listitem"><p><code class="literal">\W</code> matches any non-word character (<code class="literal">[^\w]</code>)</p></li><li class="listitem"><p><code class="literal">\\</code> matches the backslash character (<span class="quote">“<span class="quote">\</span>”</span>)</p></li></ul></div><h2><a name="d0e8234"></a>Character Class Operator</h2><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="literal">[<em class="replaceable"><code>abc</code></em>]</code> matches
            any character in the set <em class="replaceable"><code>a</code></em>,
            <em class="replaceable"><code>b</code></em> or <em class="replaceable"><code>c</code></em>.
            A leading <span class="quote">“<span class="quote">]</span>”</span> will be interpreted literally.</p></li><li class="listitem"><p><code class="literal">[^<em class="replaceable"><code>abc</code></em>]</code> matches
            any character not in the set <em class="replaceable"><code>a</code></em>,
            <em class="replaceable"><code>b</code></em> or <em class="replaceable"><code>c</code></em>.
            A leading <span class="quote">“<span class="quote">]</span>”</span> after the <span class="quote">“<span class="quote">^</span>”</span>
            will be interpreted literally.</p></li><li class="listitem"><p><code class="literal">[<em class="replaceable"><code>a-zA-Z</code></em>]</code> matches
            any character in the ranges <em class="replaceable"><code>a</code></em> to
            <em class="replaceable"><code>z</code></em> and <em class="replaceable"><code>A</code></em> to
            <em class="replaceable"><code>Z</code></em>, inclusive. A leading or trailing dash
            and a leading <span class="quote">“<span class="quote">]</span>”</span> will be interpreted literally.</p></li></ul></div><h2><a name="d0e8303"></a>Subexpressions and Backreferences</h2><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="literal">(<em class="replaceable"><code>abc</code></em>)</code> matches
            whatever the expression <em class="replaceable"><code>abc</code></em> would match,
            and saves it as a subexpression. Also used for grouping</p></li><li class="listitem"><p><code class="literal">(?<<em class="replaceable"><code>name</code></em>><em class="replaceable"><code>abc</code></em>)</code>
            matches whatever the expression <em class="replaceable"><code>abc</code></em> would match,
            and saves it as a subexpression called <em class="replaceable"><code>name</code></em>.
            Also used for grouping</p></li><li class="listitem"><p><code class="literal">(?:<em class="replaceable"><code>...</code></em>)</code> pure
            grouping operator, does not save contents</p></li><li class="listitem"><p><code class="literal">(?=<em class="replaceable"><code>...</code></em>)</code> positive
            lookahead; the regular expression will match if the text in the
            brackets matches, but that text will not be considered part of the
            match</p></li><li class="listitem"><p><code class="literal">(?!<em class="replaceable"><code>...</code></em>)</code> negative
            lookahead; the regular expression will match if the text in the
            brackets does not match, and that text will not be considered part
            of the match</p></li><li class="listitem"><p><code class="literal">(?<=<em class="replaceable"><code>...</code></em>)</code> positive
            lookbehind; the regular expression will match if the text in the
            brackets matches, but that text will not be considered part of the
            match</p></li><li class="listitem"><p><code class="literal">(?<!<em class="replaceable"><code>...</code></em>)</code> negative
            lookbehind; the regular expression will match if the text in the
            brackets does not match, and that text will not be considered part
            of the match</p></li><li class="listitem"><p><code class="literal">(?><em class="replaceable"><code>...</code></em>)</code> pure
            possessive grouping operator, does not save contents and does not
            back off during backtracking</p></li><li class="listitem"><p><code class="literal">\<em class="replaceable"><code>n</code></em></code> where 0 <
            <em class="replaceable"><code>n</code></em> < 10, matches the same thing the
            <em class="replaceable"><code>n</code></em>th subexpression matched. Can only be
            used in the search string</p></li><li class="listitem"><p><code class="literal">$<em class="replaceable"><code>n</code></em></code> where 0 <
            <em class="replaceable"><code>n</code></em> < 10, substituted with the text
            matched by the <em class="replaceable"><code>n</code></em>th subexpression. Can
            only be used in the replacement string</p></li><li class="listitem"><p><code class="literal">\k<<em class="replaceable"><code>name</code></em>></code>,
            matches the same thing the subexpression called <em class="replaceable"><code>name</code></em>
            matched. Can only be used in the search string</p></li><li class="listitem"><p><code class="literal">${<em class="replaceable"><code>name</code></em>}</code>,
            substituted with the text matched by the subexpression called <em class="replaceable"><code>name</code></em>.
            Can only be used in the replacement string</p></li></ul></div><h2><a name="d0e8430"></a>Branching (Alternation) Operator</h2><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="literal"><em class="replaceable"><code>a</code></em>|<em class="replaceable"><code>b</code></em></code>
            matches whatever the expression <em class="replaceable"><code>a</code></em> would
            match, or whatever the expression <em class="replaceable"><code>b</code></em> would
            match.</p></li></ul></div><h2><a name="d0e8448"></a>Repeating Operators</h2><p>These symbols operate on the previous atomic expression.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="literal">?</code> matches the preceding expression once or not at all</p></li><li class="listitem"><p><code class="literal">*</code> matches the preceding expression zero or more times</p></li><li class="listitem"><p><code class="literal">+</code> matches the preceding expression one or more times</p></li><li class="listitem"><p><code class="literal">{<em class="replaceable"><code>n</code></em>}</code>matches the preceding expression
            exactly <em class="replaceable"><code>n</code></em> times</p></li><li class="listitem"><p><code class="literal">{<em class="replaceable"><code>n</code></em>,<em class="replaceable"><code>m</code></em>}</code>
            matches the preceding expression between <em class="replaceable"><code>n</code></em> and
            <em class="replaceable"><code>m</code></em> times, inclusive</p></li><li class="listitem"><p><code class="literal">{<em class="replaceable"><code>n</code></em>,}</code> matches
            the preceding expression <em class="replaceable"><code>n</code></em> or more times</p></li></ul></div><h2><a name="d0e8507"></a>Greedy, Reluctant and Possessive Matching</h2><p>If a repeating operator (above) is immediately followed by a
    <code class="literal">?</code>, it behaves reluctant, that is
    the repeating operator will stop at the smallest
    number of repetitions that can complete the rest of the match.</p><p>If a repeating operator (above) is immediately followed by a
    <code class="literal">+</code>, it behaves possessive, that is
    the repeating operator will match as much characters as it can
    and will not back off during backtracking,
    even if that would allow to complete the rest of the match.</p><p>If a repeating operator (above) is not immediately followed by a
    <code class="literal">?</code> or <code class="literal">+</code>, it behaves greedy, that is
    the repeating operator will match as much characters as it can
    but it will back off character by character during backtracking,
    if that would allow to complete the rest of the match.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">On regex search</h3><p>There are some known issues with the
        <code class="literal">java.util.regex</code> library, as it stands in
        Java. In particular, it is possible to create
        regular expressions that hang the JVM, or cause stack overflow
        errors, which was not as easy to accomplish using the legacy
        <code class="literal">gnu.regexp</code> library. If you find that
        <code class="literal">gnu.regexp</code>, used in jEdit 4.2 and earlier, is
        more suitable for your search/replace needs, you can try the
        <span class="bold"><strong>XSearch plugin</strong></span>, which still
        uses it and can provide a replacement to the built-in search
        dialog.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="globs.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="using-jedit-part.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="macro-index.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix D. Glob Patterns </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix F. Macros Included With jEdit</td></tr></table></div></body></html>

¤ Dauer der Verarbeitung: 0.18 Sekunden  (vorverarbeitet)  ¤





Download des
Quellennavigators
Download des
sprechenden Kalenders

in der Quellcodebibliothek suchen




Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.


Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.


Bot Zugriff