Search code examples
regexcodasilverstripe

Syntax mode for Coda not working - Regex issue


I have the following SyntaxDefinition.xml file that I am using to create syntax highlighting for SilverStripe(.ss) files. However, I get a regex error with the following code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE syntax SYSTEM "syntax.dtd">
<syntax>

    <head>
        <name>SilverStripe Syntax</name>
        <charsintokens><![CDATA[_0987654321abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@]]></charsintokens> 
   </head>

    <states>

        <default id="Base" color="#000">

            <state id="String" color="#760f15">
                <begin><regex>"</regex></begin>
                <end><regex>(((?&lt;!\\)(\\\\)*)|^)"</regex></end>
            </state>

            <state id="Variable" color="#ff0000">
                <begin><regex>^\$([a-z])(?:)</regex></begin>
                <end><regex>[\n\r]</regex></end>
            </state>

            <import mode="PHP-HTML"/>

        </default>
    </states>
</syntax>

I want the "Variable" part of this code to color any code starting with a dollar sign, e.g. $Content.


Solution

  • I found a bit of code which seems to work:

    <regex>(\$([\w\d])+)</regex>