2

I am writing a Sublime Text 2 build configuration for grails, which includes a regular expression (perl style) to parse error messages in to file, line, column, and message parts. The errors come from the grails CLI in the following format:

{Project_Directory}/SourceFile.groovy: 19: errror_message @ line 19, column 5.

My current regex matches all four parts, but Sublime seems to require that the matches occur in order, that is match group 1 = file name, 2 = line number, 3 = column number, 4 = errror message. Grails is reporting items 3 and 4 in reverse order, so I need to write a regex that will put the column number in match group 3 and the error message in group 4. My current regex (which matches, but doesn't reverse groups 3 and 4) is as follows:

^(.+?): (\d+): (.+?) \@ line \d+, column (\d+)\.$

Any ideas? Is this even possible? Does anybody know if sublime will accept named groups instead of numbered groups?

4

1 に答える 1

3
^(.+?): (\d+): (?=.+? \@ line \d+, column (\d+)\.$)(.+?) \@

より良い (失敗時の後戻りが少ない):

^([^:]+): (\d+): (?=[^@]+ \@ line \d+, column (\d+)\.$)([^@]+) \@
于 2012-06-27T16:25:51.620 に答える