捕捉——file_regex构建系统的结果 - Capturing Build System Results - file_regex

- 此内容更新于:2015-12-20
主题:

我试图捕捉错误的行号(在本例中5)以下输出误差建立Sublimetext2:不过我不不如何创建perl风格正则表达式。我尝试过:任何一个能帮我创建一个正则表达式?来源:看文档

原文:

I'm trying to catch the error line number (5 in this example) of the following output error build in Sublimetext2 :

C:\Users\User\Desktop\new12.x (5): 'x' undeclared identifier

However I do not not how to create the Perl-style regular expression.

I have tried :

"file_regex": "^([^:]+):([0-9]+):",

Can any one help me to create the regex ?

Source :

See Documentation

网友:试一试。或。

(原文:Try ^(\\S+)\\s*\\(([^()]+)\\). OR ^([^ ]+)[ ]*[(]([^()]+)[)].)

楼主:@stribizhev谢谢它!你能建议你的评论作为一个答案?

(原文:@stribizhev Thanks it works ! could you propose your comment as an answer ?)

解决方案:
我建议:看到演示它匹配和捕获组1以外的一个或多个字符字符串的空间从一开始(文件名),然后匹配空格(s)其次是开放,然后匹配*和捕捉到组2以外的任何字符(一次或多次,然后匹配文字)。
原文:

I suggest this:

^([^ ]+)[ ]*[(]([^()]+)[)]

See demo

It matches and captures into Group 1 one or more characters other than a space from the start of string (file name), and then match whitespace(s) followed by an opening (, and then match *and capture into Group 2 any characters other than ( and ), one or more times, and then match a literal ).

网友:如果可以有一个空间内的文件名称,你可以尝试使用或从文件名(削减空间)。

(原文:In case there can be a space inside the file name, you can try using ^([^\\\\]+[^:]+)[ ]*[(]([^()]+)[)] or ^([^\\\\]+[^:]+?)[ ]*[(]([^()]+)[)] (to trim spaces from the file name).)