gtksourceview

How can I highlight "A" after "B", but do not highlight "B" itself?


Suppose I want do define a special style for every character A that appears after the character B. If I do this?

    <context id="AAA" style-ref="punct">
      <match>[B][A]</match>
    </context>

then B itself gets highlighted, which I do not want; I want to highlight only the A. How can I do this?


Solution

  • Use lookbehind:

    <match>(?&lt;=[B])[A]</match>
    

    (The < of the lookbehind operator needs to be escaped in XML.)