Date: Fri, 20 Nov 1998 10:09:25 +0000 From: Mark Ovens <marko@uk.radan.com> To: Mikhail Teterin <mi@video-collage.com> Cc: questions@FreeBSD.ORG Subject: Re: re_format Message-ID: <36553FD5.29931290@uk.radan.com> References: <199811200112.UAA17886@xxx.video-collage.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Mikhail Teterin wrote: > > Hello! > > According to the re_format's manpage, the following > > echo aXbXccc | sed 's/X.*/X/2' > > must result in aXbX -- the second occurence of X.* to be replaced > by X itself. > > Yet, it results in aXbXccc -- no changes. To the best of my > understanding of re_format, ``X.*'' is a perfectly valid regular > expression, matching anything that starts with ``X''... > r.e.'s using wildcards return the _longest_ unambiguous match, which in this case is ``XbXccc''. I think that since the (first) match reaches the end of the string that further matches are not searched for, therefore the sed substitution fails. FWIW echo aXbXccc | sed 's/X.*/X/2' gives the same result on SunOS 4.1.3 grep does the same thing. If it found _both_ matches it would return the line twice. gppsun4:/users2/radan{4}% cat > scrap aXbXccc gppsun4:/users2/radan{5}% grep 'X.*' scrap aXbXccc gppsun4:/users2/radan{6}% > Thanks for any hints. > > -mi > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message -- Trust the computer industry to shorten Year 2000 to Y2K. It was this thinking that caused the problem in the first place. Mark Ovens, CNC Applications Engineer, Radan Computational Ltd. Bath, Avon, England. Sheet Metal CAD/CAM Solutions mailto:marko@uk.radan.com http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36553FD5.29931290>