home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!warwick!uknet!comlab.ox.ac.uk!mbeattie
- From: mbeattie@black.ox.ac.uk (Malcolm Beattie)
- Newsgroups: comp.unix.questions
- Subject: Re: A simple question about lex!
- Message-ID: <1992Dec23.104418.27174@black.ox.ac.uk>
- Date: 23 Dec 92 10:44:18 GMT
- References: <1h7i58INNms4@function.mps.ohio-state.edu>
- Organization: Oxford University Computing Service, 13 Banbury Rd, Oxford, U
- Lines: 53
- Originator: mbeattie@black
-
- In article <1h7i58INNms4@function.mps.ohio-state.edu> ren@function.mps.ohio-state.edu (Liming Ren) writes:
- >This is the first time I am using lex. I am puzzled by the following problem;
- >
- >I want to match
- >beginning of line .I followed by one or more space ,then a number and then
- >newline. For example
- >.I 123\n
- >.I 234\n
- >
- >
- >I tested ^\.I[ ]+ [0-9]+$ , ^\.I[ ]+[0-9]+$ and ^\.I [ ]+ [0-9]+$,
- > none of them works!
- >
- >I tried ^\.I" "[0-9]+$ , it works only for patten with one space in between.
- >Please help me to find the correct specification.
- >
- >
- >Many thanks!
-
- The following works for me (DEC5500, Ultrix 4.2A).
- Notice that your `$' finds the number at end-of-line but
- doesn't swallow the \n---that gets passed in as the next character.
-
- [~/src]black% cat foo.l
- %%
- ^\.I[ ]+[0-9]+$ { puts("Found .I line"); }
- [~/src]black% lex foo.l
- [~/src]black% cc lex.yy.c -ll
- [~/src]black%
- [~/src]black% cat fooin
- The quick brown fox
- .I 1234
- .I 567
- .I blah
- is getting tired of jumping
- [~/src]black% ./a.out < fooin > fooout
- [~/src]black% cat fooout
- The quick brown fox
- Found .I line
-
- Found .I line
-
- .I blah
- is getting tired of jumping
- [~/src]black%
-
- --Malcolm
-
- --
- Malcolm Beattie <mbeattie@black.ox.ac.uk> | I'm not a kernel hacker
- Oxford University Computing Services | I'm a kernel hacker's mate
- 13 Banbury Road, Oxford, OX2 6NN (U.K.) | And I'm only hacking kernels
- Tel: +44 865 273232 Fax: +44 865 273275 | 'Cos the kernel hacker's late
-