PageRenderTime 235ms CodeModel.GetById 220ms app.highlight 5ms RepoModel.GetById 7ms app.codeStats 0ms

/www/tags/NOV_07_2009/htdocs/users-guide/mode-rule-span-regexp.html

#
HTML | 30 lines | 30 code | 0 blank | 0 comment | 0 complexity | 527ea40d6b2c068aed742abdf1f35e0e MD5 | raw file
 1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>The SPAN_REGEXP Tag</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="jEdit 4.3 User's Guide"><link rel="up" href="writing-modes.html" title="Chapter 10. Mode Definition Syntax"><link rel="prev" href="mode-rule-span.html" title="The SPAN Tag"><link rel="next" href="mode-rule-eol-span.html" title="The EOL_SPAN Tag"></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">The SPAN_REGEXP Tag</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="mode-rule-span.html">Prev</a> </td><th width="60%" align="center">Chapter 10. Mode Definition Syntax</th><td width="20%" align="right"> <a accesskey="n" href="mode-rule-eol-span.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mode-rule-span-regexp"></a>The SPAN_REGEXP Tag</h2></div></div></div><p>The <code class="literal">SPAN_REGEXP</code> rule is similar to the
 2        <code class="literal">SPAN</code> rule except the start sequence is taken to be a
 3        regular expression. In addition to the attributes supported by the
 4        <code class="literal">SPAN</code> tag, the following attributes are
 5        supported:</p><div class="itemizedlist"><ul type="disc"><li><p><code class="literal">HASH_CHAR</code> - a literal string which must
 6                be at the start of a regular expression.</p></li><li><p><code class="literal">HASH_CHARS</code> - a list of possible literal
 7                characters, one of which must match at the start of the regular
 8                expression.</p></li></ul></div><p><code class="literal">HASH_CHAR</code> and <code class="literal">HASH_CHARS</code>
 9        attributes are both optional, but you may only specify one, not both. If
10        both are specified, <code class="literal">HASH_CHARS</code> is ignored and an
11        error is shown. Whenever possible, use a literal prefix to specify a
12        <code class="literal">SPAN_REGEXP</code>. If the starting prefix is always the
13        same, use <code class="literal">HASH_CHAR</code> and provide as much prefix as
14        possible. Only in rare cases would you omit both attributes, such as the
15        case where there is no other reliable way to get the highlighting you
16        need, for example, with comments in the Cobol programming
17        language.</p><p>The regular expression match cannot span more than one line. Any
18        text matched by groups in the <code class="literal">BEGIN</code> regular
19        expression is substituted in the <code class="literal">END</code> string. See
20        below for an example of where this is useful.</p><p>Regular expression syntax is described in <a class="xref" href="regexps.html" title="Appendix E. Regular Expressions">Appendix E, <i>Regular Expressions</i></a>.</p><p>Here is a <code class="literal">SPAN_REGEXP</code> rule that highlights
21        &#8220;<span class="quote">read-ins</span>&#8221; in shell scripts:</p><pre class="programlisting">&lt;SPAN_REGEXP HASH_CHAR="&amp;lt;" TYPE="LITERAL1" DELEGATE="LITERAL"&gt;
22    &lt;BEGIN&gt;&lt;![CDATA[&lt;&lt;[\p{Space}'"]*([\p{Alnum}_]+)[\p{Space}'"]*]]&gt;&lt;/BEGIN&gt;
23    &lt;END&gt;$1&lt;/END&gt;
24&lt;/SPAN_REGEXP&gt;</pre><p>Here is a <code class="literal">SPAN_REGEXP</code> rule that highlights
25        constructs placed between <code class="literal">&lt;#ftl</code> and
26        <code class="literal">&gt;</code>, as long as the <code class="literal">&lt;#ftl</code> is
27        followed by a word break:</p><pre class="programlisting">&lt;SPAN_REGEXP TYPE="KEYWORD1" HASH_CHAR="&amp;lt;" DELEGATE="EXPRESSION"&gt;
28    &lt;BEGIN&gt;&amp;lt;#ftl\b&lt;/BEGIN&gt;
29    &lt;END&gt;&amp;gt;&lt;/END&gt;
30&lt;/SPAN_REGEXP&gt;</pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="mode-rule-span.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="writing-modes.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="mode-rule-eol-span.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">The SPAN Tag </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> The EOL_SPAN Tag</td></tr></table></div></body></html>