在Atom包中,如何在语法中重叠模式?

Ton*_*Nam 8 regex custom-formatting atom-editor

我想更进一步,更多的东西.例如,我想设置以下样式:

setting1 = 4
setting2 = 192.168.1.12
etc...
Run Code Online (Sandbox Code Playgroud)

我想把所有东西都设置在=蓝色的左边,一切都设置为右边的紫色.

问题是原子正则表达式引擎不支持负向前瞻或正向前瞻.结果,我尝试使用beginend指令,但仍然无法正常工作.换句话说,我尝试过:

{
  # section reference
  'begin': '^\\s*.*?=' # match a line that contains an = sign
  'end': '.+$' # continue until the end of the line
  'match': '^\\s*[^=]*'  #only match everything that is not an equal sign 
  'name': 'blue' #style it with the blue style
},
Run Code Online (Sandbox Code Playgroud)

所以基本上,我需要它看起来像这样:

在此输入图像描述

有任何想法吗?

Ton*_*Nam 3

我想出了这个解决方案:(reules.cson)

'scopeName': 'source.conf'
'name': 'CONF'
'fileTypes': ['CONF']
'patterns': [     
  {
    # equality
    'match': '(?x) ^ ([^=;]+) (=)  (.+?)\\n'
    'captures':
      '1' :
        'name' : 'blue'
      '2' :
        'name' : 'yellow'
      '3' :
        'name' : 'purple'
  }

]
Run Code Online (Sandbox Code Playgroud)

您可以为每个捕获设置不同的样式。