home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!spool.mu.edu!agate!doc.ic.ac.uk!warwick!pavo.csi.cam.ac.uk!mbfs.bio.cam.ac.uk!seb1005
- From: seb1005@mbfs.bio.cam.ac.uk (Steven Brenner)
- Subject: Leftmost longest?
- Message-ID: <1993Jan26.131142.6158@infodev.cam.ac.uk>
- Sender: news@infodev.cam.ac.uk (USENET news)
- Nntp-Posting-Host: mbfs.bio.cam.ac.uk
- Organization: U. of Cambridge, England
- Date: Tue, 26 Jan 1993 13:11:42 GMT
- Lines: 24
-
- I want to find the first number after a key word, so what I really
- want to do is something like:
-
- ($mynumber) = /R[- \n]+VALUE.*(0.\d+)/;
-
- but where the .* in the middle matches the shortest string to make
- the whole pattern match rather than the longest.
-
- Is there any straightforward way of doing this? What I've done
- thus far is:
-
-
- if (($s) = /(R[- \n]+VALUE)/) {
- $i = index ($_,$s);
- ($mynumber) = (substr($r3,$i) =~ /(0.\d+)/);
- }
-
-
- --
- Steven E. Brenner | Internet seb1005@mbfs.bio.cam.ac.uk
- Department of Biochemistry | JANET seb1005@uk.ac.cam.bio.mbfs
- University of Cambridge | Laboratory +44 223 333671
- Tennis Court Road | Home +44 223 314964
- Cambridge CB2 1QW, UK | Lab Fax +44 223 333345
-