From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <7359f0490810261423l2c8ff4b7q8ac7801d426f27c@mail.gmail.com> Date: Sun, 26 Oct 2008 14:23:59 -0700 From: "Rob Pike" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@9fans.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <27fc6dd0023ba76f35ee6409157db321@terzarima.net> Subject: Re: [9fans] non greedy regular expressions Topicbox-Message-UUID: 2743f7e8-ead4-11e9-9d60-3106f5b1d025 The ability to put \1 in the right hand side of a substitution was done by jason@ at the Uni of Sydney, but after the Sam papers were published. It was a welcome feature that added special functionality to the 's' command within Sam. (Ed(1) had the feature, within its limited regexps, long before, of course.) -rob On Fri, Oct 24, 2008 at 12:56 PM, Rudolf Sykora wrote: > 2008/10/24 Charles Forsyth : >>>If I try sth. like >>>/( b(.)b)/a/\1\2/ >>>on >>>bla blb 56 >>>I get >>>bla blb\1\2 56 >>>which is not quite what I want... How then? (I'd like to get 'bla blblblb 56') >> >> echo bla blb 56 | sed 's/( b(.)b)/&\1\2/' >> bla blb blbl 56 >> >> similarly use `s' not `a' in sam. > > > Yes. But my question was more subtle. I know it can be done with the > 's' command in sam now. But I asked sth. different. The documentation > (paper about sam) says 's' is redundant. But it seems (only seems > since documentation says nothing), that submatches only work with the > 's' command. If this is true 's' is not redundant, since if it weren't > there you would not have any chance to use \1, \2, etc. > That was the reason I wanted to have my example rewritten WITHOUT the > 's' command... > > But anyway thanks! > Ruda > >