On 19 July 2012 23:32, Nick Treleaven <[email protected]> wrote: > On 19/07/2012 09:30, Lex Trotman wrote: >> >> On 19 July 2012 17:38, Laszlo Nagy<[email protected]> wrote: >>> >>> Here is an example. There are two kinds of error messages that I can get >>> - >>> >>> because there can be an error in the compiler that I'm working on, and >>> also >>> there can be an error in the file that is being compiled: >>> >>> Error message (type one): >>> >>> File "/home/gandalf/Python/Lib/shopzeus/scripts/ssdlc.py", line 23, in >>> <module> >>> >>> Regexp (type one): >>> >>> \s*File\s\"([^\"]+)\", line (\d+), in\s*(.*) >>> >>> >>> Error message (type two): >>> >>> /home/gandalf/Python/Lib/shopzeus/demos/ssdl/test/test.ssdl:53:9:Syntax >>> error >>> >>> Regexp (type two): >>> >>> ([^:]+):([^:]+):[^:]+:([^:]+) >>> >>> Both of these errors can happen then I press F8, so I would like to >>> capture >>> both messages if possible. This is what I have tried: >>> >>> (?:\s*File\s\"([^\"]+)\", line (\d+), >>> in\s*(.*))|(?:([^:]+):([^:]+):[^:]+:([^:]+)) >>> >>> But it does not capture errors in the compiler. Maybe my regular >>> expression >>> is wrong. Or maybe the non-capturing group "?:" does not work. > > > I couldn't find the problem with that regex exactly, but it seems to be the > [^\"]+ part. > > This seems to work here: > File\s(\S+?), line (\d+)|(\S+):(\S+): > > It might need tweaking though. The regex doesn't have to match the entire > line. > > Also, the 2nd regex seems to be unnecessary as Geany already tries this > pattern as a built in. >
Good point, but it can't be quite a correct match or it would have worked for Laszlo. > >> IIUC Match group numbering is in the order they occur in the regex, >> not the order they match, so the "type two" regex groups are 3 and 4 >> which geany ignores. The method isn't really suited to mixed > > > No, the type two matches start from 1. No, matches are numbered in the order of their ( and don't change even if the previous ones don't match because they were in a different alternate branch. The ( after File is 1, the ( after line is 2, the two ( in :([^:]+):[^:]+:([^:]+)) are 3 and 4 so they would be ignored by geany since we only look at one and two. Cheers Lex > > Nick > > _______________________________________________ > Geany mailing list > [email protected] > https://lists.uvena.de/cgi-bin/mailman/listinfo/geany _______________________________________________ Geany mailing list [email protected] https://lists.uvena.de/cgi-bin/mailman/listinfo/geany
