## The SPAN_REGEXP Tag

The `SPAN_REGEXP` rule is similar to the `SPAN` rule except the start sequence is taken to be a regular expression. In addition to the attributes supported by the `SPAN` tag, the `HASH_CHAR` attribute must be specified. It must be set to the first character that the regular expression matches. This rules out using regular expressions which can match more than one character at the start position. The regular expression match cannot span more than one line, either.

Any text matched by groups in the `BEGIN` regular expression is substituted in the `END` string. See below for an example of where this is useful.

Regular expression syntax is described in Appendix E, Regular Expressions.

Here is a `SPAN_REGEXP` rule that highlights “read-ins” in shell scripts:

    <SPAN_REGEXP HASH_CHAR="<" TYPE="LITERAL1" DELEGATE="LITERAL">
        <BEGIN><![CDATA[<<[[:space:]'"]*([[:alnum:]_]+)[[:space:]'"]*]]></BEGIN>
        <END>$1</END>
    </SPAN_REGEXP>

Here is a `SPAN_REGEXP` rule that highlights constructs placed between `<#ftl` and `>`, as long as the `<#ftl` is followed by a word break:

    <SPAN_REGEXP TYPE="KEYWORD1" HASH_CHAR="&lt;" DELEGATE="EXPRESSION">
        <BEGIN>&lt;#ftl\&gt;</BEGIN>
        <END>&gt;</END>
    </SPAN_REGEXP>