Syntax highlighting with AvalonEdit

Issue

I am trying to write a regex for AvalonEdit.TextEditor to mark everything after the second | a certain color.

Example(value should be a color):

action|key|value

I am trying something like this but it doesn’t work because I can’t specify the group I wanna color.

^[^\|]*\|[^\|]*\|(?P<value>[^\|]*)

Any ideas?

Solution

Try this: (?<=[^\|]+\|[^\|]+\|)(?<value>[^\|]+)

The positive look-behind (?<=) will make sure action and key are not part of the match.

Normally you shouldn’t use non-fixed length look-behinds but maybe this works for you.

Answered By – Manfred Radlwimmer

Answer Checked By – Willingham (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.