From: Stefano Crocco Date: 2008-03-03T19:17:58+09:00 Subject: Re: Patterns for error messages Alle Monday 03 March 2008, Victor 'Zverok' Shepelev ha scritto: > >This should take care of all the four patterns: > > > >/^(?:.*:\d+:in\s+`require':\s+|\s+\^\s+from\s+)?(.*)(?=:\d+)/ > > But not this one: > > "./../app/models/teachers.rb:7:in `initialize': undefined local variable" I think this is a different matter: here, we're in the first case (the simplest) and the regexp correctly gives: "./../app/models/teachers.rb" This is the path of the file where the error occurs, relative to the directory where ruby was started. What would you like to get here? > (not saying about that most of regexp engines too dumb for doing ?: and ?= > groups). Are they? I didn't try many editors (in particular, kate and vim on linux), but they all support them. At any rate, I think you can do without them. If you replace the initial (?: with a simple (, you'll get the name of the file in the second group instead of the first. The look-ahead at the end can be removed by replacing (.*) with [^:]*. which matche any character except the column. This has the side effect of not working with filenames containing ':' (this is the reason I used the look-ahead). Stefano