Rule using regex

How do I create a rule to check for {, : and }?

Correct: {OCyan}Pitched{VAR07:5A}Sold{VAR07:6C}Profit{White}

Wrong: {oCyan}Pitched{VAR075A}Sold{VAR07:6CProfit{White

When I try to create the rule, it causes an unexpected error.

<rule id="TOOL_CODE" name="Tool_Code">
 <pattern case_sensitive='yes'>
  <token>{</token>
  <token></token>
  <token>:</token>
  <token></token>
  <token>}</token>
 </pattern>
 <message>Códigos da tool entre chaves.</message>
 <example correction=''>{VAR12:32}</example>
 <example>{VAR12:32}</example>
</rule>
  • there is no value in ‘case_sensitive’, since there is no test on a letter
    Furthermore, could you give a wrong example, and what the correction should be?

The problem in your example ({VAR12:32}) is the tokenization. The current tokenization for this string is this:
imatge
Text can be analyzed online here: Text Analysis - LanguageTool

You will need a pattern like this:

<pattern case_sensitive='yes'>
  <token>{</token>
  <token regexp="yes">.+:.+</token>
  <token>}</token>
 </pattern>

This is weird. : is not a word char, or is it?

Thank you all for your answers.

The correct way: {VAR07:42}{VAR12:30}/10{VAR07:5D}{VAR07:E2}{VAR12:31}{VAR07:32}{VAR12:32}

It is supposed to be wrong if ‘{’ ‘}’ is missing or VAR is not in caps. Those are the errors I need to check for.

When I use the rule… any text {VAR12:32} is highlighted as an error by the rule I created, but I want the rule to highlight an error when, for example; {VAR12:32} or {var12:32}.

This has been happening with every rule I have tried to create.
I tried to create a rule to check the string “--------------------------------------------------End–”
This is the correct sequence. I want to check 50 “-” before the word End and 2 “-” after.
The rule marks it as wrong when the string is correct and does not mark it at all when it should be wrong, with 49 “-” before End.

Am I doing the rule the wrong way?

You have to write a pattern that matches what you want to dectect as an error. To match {var12:32}, use:

<pattern case_sensitive='yes'>
  <token>{</token>
  <token regexp="yes">var\d+:\d+</token>
  <token>}</token>
 </pattern>

To check “--------------------------------------------------End–”, you can use antipatterns. In the pattern, put all incorrect patterns you want to detect, and in the antipattern put the correct version. See: Development Overview | dev.languagetool.org
Because of the repetitions, you will need several rules. Some for detecting more than 50 hyphens or 2 hyphens and some for detecting less than 50 / 2 hyphens.
About repetitions, see Development Overview | dev.languagetool.org