Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcs!mnetor!seismo!hao!bill From: bill@hao.UUCP Newsgroups: net.unix Subject: Regular expressions in Lex. Message-ID: <158@hao.UUCP> Date: Mon, 21-Jul-86 12:41:30 EDT Article-I.D.: hao.158 Posted: Mon Jul 21 12:41:30 1986 Date-Received: Mon, 21-Jul-86 21:41:52 EDT Organization: High Altitude Obs./NCAR Boulder, CO Lines: 23 Keywords: pattern matching I'm trying to use Lex to dig out the OPEN statements in a fortran source file. Of course, I have to be aware of continuation lines, so I use a regular expression (see the example in 1.) to dig out the single continuation line. 1. ^[^Cc].*open[ ]*\(.*\n[ .].*\) printf ("%s", yytext); This seems to work fine. But when I try to find multiple continuation lines with the pattern given in 2., I don't even get the single continuation lines. 2. ^[^Cc].*open[ ]*\(.*\n[[ .].*[\n\)]]+ printf ("%s", yytext); My questions are: a) Isn't the r.e. [[ .].*[\n\)]]+ valid? b) If it is, what am I doing wrong? i.e. why don't it work? c) Do you have any suggestions on a better reference to Lex than that given in the Unix Programmer's Manual, III, by Lesk and Schmidt? Thanks in advance for any ideas or suggestions. Bill Roberts NCAR/HAO Boulder, CO !hao!bill