简体   繁体   English

使用AvalonEdit突出显示语法

[英]Syntax highlighting with AvalonEdit

I am trying to write a regex for AvalonEdit.TextEditor to mark everything after the second | 我正在尝试为AvalonEdit.TextEditor写一个正则表达式来标记第二个|之后的所有内容 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>[^\\|]+) 试试这个: (?<=[^\\|]+\\|[^\\|]+\\|)(?<value>[^\\|]+)

The positive look-behind ( ?<= ) will make sure action and key are not part of the match. 积极的后卫( ?<= )将确保actionkey不是比赛的一部分。

Normally you shouldn't use non-fixed length look-behinds but maybe this works for you. 通常你不应该使用非固定长度的后视镜,但这可能适合你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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