Syntax highlighting for regular expressions

In DGT-OmegaT 3.0 update 15 we added the possibility, when you edit a regular expression, to show in colors the characters which have a special meaning. In other terms, we have a small form of syntax highlighting.

This actually works for all search screens and split window, but not yet for the segmentation editor, which is based on JTable, making it more complicated.

Actually this is based on highlighters, and for that reason, colors are applied to the background, not to the font. Using attributes, and making it configurable, will be studied in the future.

The syntax highlighter supports 3 modes:

  • Regular expression
    • Meta-characters in orange : ( ) [ ]  + * ?
      in branch 3.6 and 3.7, this also works with modifiers, for example (?i:something)
    • Escape sequences (backslash + any character, for example \s) in cyan
      Note that the highlighter makes difference between a non-escaped meta-character, for example + and the corresponding escape sequence, for example \+
  • Replacement string
    • Variable in green, for example $1
    • Case-replacement sequences in cyan: \U, \u \E \L \l
  • Non-regular expression (i.e. for exact and keyword search):
    • Only jokers in orange : * and ?
      Note that since there is no way to escape a joker in exact and keyword search, these two characters will always be considered as jokers in the string and for that reason, appear in orange.

 

 

Add new comment