简体   繁体   中英

Syntax highlighting with AvalonEdit

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM