Regular Expression Rules

Regular expression rules are applied to the document after word and character rules. They are applied to any group of characters that match the regular expression code within the rule

All regular expression rules must sit within the <regExRules></regExRules> tags within the XML file.

The following is an example of a regular expression rule definition:

    <rule active="true" bold="true" underline="false" italic="false" color="black">
      <regExp>
        <![CDATA[\b(0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012])[- /.](19|20)?[0-9]{2}\b]]>
      </regExp>
    </rule>

Rule Attributes

The attributes for the rule are all optional and are as follows:

active if true then this rule is applied, if false then this rule is ignored. If not specified then it defaults to "true"

bold if true then any characters that match this rule are made bold. If not specified then it defaults to "false"

underline if true then any characters that match this rule are underlines. If not specified then it defaults to "false"

italic if true then any characters that match this rule are made italic. If not specified then it defaults to "false"

color if true then any characters that match this rule have their fore colour set to this value. It can either be a word for the most common colours (blue, red, green, darkblue, etc) or it can be a hex code. If not specified then it defaults to "black". If you specify an invalid colour name or code then ChromaCode will throw an exception when the rule file is loaded and parsed

Regular Expression Pattern

The regular expression pattern to use for searching through the characters should be placed within the <regExp></regExp> tags. As regular expression rules can be quite complicated and contain characters that might have other uses in XML then it is strongly recommended that you place the pattern within a <![CDATA[]]> tag.

Last edited May 4, 2011 at 9:52 PM by NybbleUK, version 1

Comments

No comments yet.