SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

AvalonEdit highlight rule : support for regex lookbehind

Last post 12-07-2016 1:48 AM by jbell. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-29-2016 1:13 AM

    • jbell
    • Not Ranked
    • Joined on 04-22-2009
    • Posts 2

    AvalonEdit highlight rule : support for regex lookbehind

    Hi,

    Using AvalonEdit 5.0.3. There does not appear to be support for regex lookbehind either positive or negative. Lookahead works fine. It appears it chokes on the "less than" character in the lookbehind sytntax.

    For instance I have the folloing line where I want to capture the entire line except for the word Note at the begining:

    Note Example of IMO 562, severe wind and rolling

    Using the following rule:
    <Rule color="Note">
    (?<=Note).*$
    </Rule>
    Results in the following error loading the .xshd file

    Name cannot begin with the '=' character

  • 12-03-2016 9:57 PM In reply to

    Re: AvalonEdit highlight rule : support for regex lookbehind

    You need to XML-escape the '<' character:

    <Rule color="Note">
    (?&lt;=Note).*$
    </Rule>
  • 12-07-2016 1:48 AM In reply to

    • jbell
    • Not Ranked
    • Joined on 04-22-2009
    • Posts 2

    Re: AvalonEdit highlight rule : support for regex lookbehind

    Thanks Daniel, that works. But there is another problem. The rule works when opening a file that has a line that matches the lookbehind rule. But, when typing the line, the editor throws an exception as soon as the look behind matches, so if I type Note it crashes before I can type anything else. The exception is:

    A highlighting rule matched 0 characters, which would cause an endless loop.

    Is there any work around for this, that will allow me to keep typing?

    Thanks again.

Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.