home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!spillman!tye
- From: tye@spillman.uucp (E. Tye McQueen)
- Subject: Re: Leftmost longest?
- Message-ID: <1993Jan27.171211.32439@spillman.uucp>
- Date: Wed, 27 Jan 1993 17:12:11 GMT
- References: <1993Jan26.131142.6158@infodev.cam.ac.uk>
- Organization: Spillman Data Systems
- Lines: 33
-
- seb1005@mbfs.bio.cam.ac.uk (Steven Brenner) writes:
- )
- ) ($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.
-
- Since the pattern after ".*" always starts with "0", you can do:
-
- ($mynumber) = /R[- \n]+VALUE[^0]*(0.\d+)/;
-
- Though it won't work for "R - VALUE 0 0.5", but I doubt that will
- be a problem. You could elaborate on this to fix it and other problems
- but it probably wouldn't be worth the loss of readability/speed.
- Something silly like (which probably doesn't work):
-
- ($mynumber) = /R[- \n]+VALUE([^0]*(0[^.]|0.\D))*(0.\d+)/;
-
-
- ) if (($s) = /(R[- \n]+VALUE)/) {
- ) $i = index ($_,$s);
-
- $i= length($`);
-
- might be better (and may be off by one or so).
-
- ) ($mynumber) = (substr($r3,$i) =~ /(0.\d+)/);
- ) }
-
- tye@spillman.com Tye McQueen, E.
- ----------------------------------------------------------
- Nothing is obvious unless you are overlooking something.
- ----------------------------------------------------------
-