Page 1 of 1

Regex to match PHP output

Posted: Tue Aug 29, 2006 9:42 pm
by kAlvaro
I've created a tool to launch PHP scripts (command line interface). Now I'm trying to add a regex (POSIX syntax) so I can double click on errors and jump to the offending line. Errors look like this:

Code: Select all

Parse error: parse error, unexpected T_STRING in C:\tmp\borrame.php on line 31
Warning: Wrong parameter count for mysql_query() in C:\tmp\borrame.php on line 60
My first attemp was:

Code: Select all

 in (.*) on line ([0-9]+)$
I then tried:

Code: Select all

.*([0-9]+)$
... and many other variations... I've tried to escape parenthesis... I've tried everything... to no avail. I always get a "cannot jump to element under cursor" error message. What vital point am I missing?

Posted: Wed Aug 30, 2006 9:17 am
by ben_josephs
It seems to attempt a match only at the beginning of the line. Try
.* in (.*) on line ([0-9]+)$

Posted: Wed Aug 30, 2006 8:27 pm
by kAlvaro
You're right, it seems the key is that the expression must match the beginning of the line (a sort of implicit ^). Your regex works fine. Actually, even the second of my examples works fine today. Damn computer goblins.