home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / perl / 7993 < prev    next >
Encoding:
Text File  |  1993-01-26  |  1.2 KB  |  36 lines

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