Page 1 of 1

RegEx for Lahey Fortran

Posted: Fri Apr 21, 2006 3:52 pm
by greatrussian
I am new to regular expressions, however, I managed to figured out one for Lahey fortran yesterday, but for some reason it got deleted overnight, and now I can't recall it.

Error codes look like this:

Compiling program unit test01 at line 1:
2018-S: "test.for", line 7: When IMPLICIT NONE is specified, x must be declared in a type declaration statement.
Encountered 1 error, 0 warnings in file test.for.

This does not work:
^.+"\([:alpha:]+\)".+\([:digit:]+\)
File=1
Line=2

What am I doing wrong?

Posted: Fri Apr 21, 2006 6:57 pm
by MudGuard

Code: Select all

^[^"]*"([^"]+)", line ([0-9]+):
should do the job. If you have posix switched off, add a \ before each ( and ).

What it does:
^
start at the beginning
[^"]*
any number of non-quotes
"
the first quote, starting the file name
([^"]+)
any number of non-quotes (will be remembered) - the file name
"
the second quote, finishing the file name
, line
the stuff between file name and line number
([0-9]+)
any number of digits (the line number, will be remembered).
:
the colon after the line number




[:alpha:] allows one of the characters ":", "a", "l", "p", "h".
[:alpha:] can be used within a character class, i.e. within [].
(similar for [:digit:] and the other character class operators).

But even [[:alpha:]] would not work, as your filename contains other characters than letters (e.g. the dot).

Posted: Mon Apr 24, 2006 2:17 pm
by greatrussian
Thanks, I hadn't realized that [:alpha:] would exclude the file name because of the period.