0

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.

stema
  • 90,351
  • 20
  • 107
  • 135
Te Riu Warren
  • 229
  • 2
  • 5
  • 13

2 Answers2

0

Try:

 <begin><regex>^\$[^\r\n]+</regex></begin>

or

<begin><regex>^\$</regex></begin>

depending on how it works

Bohemian
  • 412,405
  • 93
  • 575
  • 722
0

I found a bit of code which seems to work:

<regex>(\$([\w\d])+)</regex>
Te Riu Warren
  • 229
  • 2
  • 5
  • 13