From owner-freebsd-questions Fri Nov 20 02:11:12 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id CAA13337 for freebsd-questions-outgoing; Fri, 20 Nov 1998 02:11:12 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from post.mail.demon.net (post-12.mail.demon.net [194.217.242.41]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id CAA13332 for ; Fri, 20 Nov 1998 02:11:10 -0800 (PST) (envelope-from marko@uk.radan.com) Received: from [158.152.75.22] (helo=uk.radan.com) by post.mail.demon.net with smtp (Exim 2.053 #1) id 0zgnWP-00063O-00; Fri, 20 Nov 1998 10:10:38 +0000 Organisation: Radan Computational Ltd., Bath, UK. Phone: +44-1225-320320 Fax: +44-1225-320311 Received: from beavis.uk.radan.com (beavis [193.114.228.122]) by uk.radan.com (8.6.10/8.6.10) with SMTP id KAA02781; Fri, 20 Nov 1998 10:10:08 GMT Received: from uk.radan.com (gppsun4) by beavis.uk.radan.com (4.1/SMI-4.1) id AA05114; Fri, 20 Nov 98 10:10:06 GMT Message-Id: <36553FD5.29931290@uk.radan.com> Date: Fri, 20 Nov 1998 10:09:25 +0000 From: Mark Ovens Organization: Radan Computational Ltd X-Mailer: Mozilla 4.03 [en] (X11; I; SunOS 4.1.3_U1 sun4m) Mime-Version: 1.0 To: Mikhail Teterin Cc: questions@FreeBSD.ORG Subject: Re: re_format References: <199811200112.UAA17886@xxx.video-collage.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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