From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <2639078ba1a669e2ca3eeb93d1ae1372@mteege.de> From: Matthias Teege To: 9fans@cse.psu.edu MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] sam regexp coverage Date: Sun, 9 May 2004 16:28:17 +0000 Topicbox-Message-UUID: 750647b2-eacd-11e9-9e20-41e7f4b1d025 I have another small problem with sam and regexp. I have a text with a lot of constructs like this one: Hello world http://my.domain:"This is a link" more text and http://another.domain:"This is another link" follows more text Now I try to translate the link in html syntax with ,x/(http.*)\:\".*\" s/(http.*):\"(.*\n*.*)\"/\2<\/a>/ The problem is, that the regexp matches both "links" not only the first ore the second one. I've tried to find a better one but its hopeless. ;-) Thanks for any hint Matthias From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <7359f04904050909514b882f5c@mail.gmail.com> From: Rob Pike To: 9fans@cse.psu.edu Subject: Re: [9fans] sam regexp coverage In-Reply-To: <2639078ba1a669e2ca3eeb93d1ae1372@mteege.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <2639078ba1a669e2ca3eeb93d1ae1372@mteege.de> Date: Sun, 9 May 2004 09:51:44 -0700 Topicbox-Message-UUID: 750f6ca2-eacd-11e9-9e20-41e7f4b1d025 your problem is that .* is greedy. instead of .*" (maximal sequence of anything followed by quote) write [^"]*" (maximal sequence of not-quote, followed by quote). you don't need the backslashes for : and ". -rob On Sun, 9 May 2004 16:28:17 0000, Matthias Teege wrote: > > I have another small problem with sam and regexp. I have a text > with a lot of constructs like this one: > > Hello world http://my.domain:"This is a link" more text and > http://another.domain:"This is another link" follows more text > > Now I try to translate the link in html syntax with > ,x/(http.*)\:\".*\" s/(http.*):\"(.*\n*.*)\"/\2<\/a>/ > > The problem is, that the regexp matches both "links" not only > the first ore the second one. I've tried to find a better one but > its hopeless. ;-) > > Thanks for any hint > Matthias > From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <0a0d01c43625$1763c1c0$265d7d50@SOMA> From: "boyd, rounin" To: <9fans@cse.psu.edu> References: <2639078ba1a669e2ca3eeb93d1ae1372@mteege.de> Subject: Re: [9fans] sam regexp coverage MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Date: Mon, 10 May 2004 02:23:57 +0200 Topicbox-Message-UUID: 752cc2ac-eacd-11e9-9e20-41e7f4b1d025 x (and y) are iteration operators. so ... once you understand them they are extremely powerful. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <0a2901c4362a$2e20e2d0$265d7d50@SOMA> From: "boyd, rounin" To: <9fans@cse.psu.edu> References: <2639078ba1a669e2ca3eeb93d1ae1372@mteege.de> <7359f04904050909514b882f5c@mail.gmail.com> Subject: Re: [9fans] sam regexp coverage MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Date: Mon, 10 May 2004 03:00:14 +0200 Topicbox-Message-UUID: 7538f0f4-eacd-11e9-9e20-41e7f4b1d025 > your problem is that .* is greedy. yes, as it always has been (ie. not a sam related problem).