delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/07/22/23:55:26

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <004301c350ce$33db4900$5c16989e@oemcomputer>
Reply-To: "Peter S Tillier" <peter DOT tillier AT btinternet DOT com>
From: "Peter S Tillier" <peter DOT tillier AT btinternet DOT com>
To: "Cygwin" <cygwin AT cygwin DOT com>
Cc: "Brian Dessent" <brian AT dessent DOT net>
References: <000701c34b9a$1c7e6c80$6fc82486 AT medschool DOT dundee DOT ac DOT uk> <3F155A90 DOT 2173F884 AT dessent DOT net>
Subject: Re: Cygwin's vanilla sed : capabilities and limitations
Date: Wed, 23 Jul 2003 04:55:04 +0100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

Brian Dessent wrote:
> fergus AT bonhard DOT uklinux DOT net wrote:
>
>> Q1. Querying info sed reveals the expression matcher to be "greedy",
>> matching the longest possible string. Is there a way to make it
>> match the shortest possible, so that echo aaabbbccc | sed 's/^.*b//'
>> (altered but similar) grabs aaab not aaabbb?
>
> If you have perl available (or just a tool that uses perl-compatible
> regexps, i.e. grep -P) you can add the '?' character after any
> qualifier to get the non-greedy version, i.e. '*?' is the non-greedy
> '*', '??' is the non-greedy '?', etc.  But this is a feature of pcre,
> which I don't believe applies to sed in any shape or form.  However,
> most sed scripts are pretty easy to do in perl with little
> modification, so if you
> require this function that's what I'd do.
>
> Brian

The GNU sed maintainer Paolo Bonzini also maintains a version of sed
called ssed (super sed) that does support PCREs in addition to BREs and
EREs (which are both now supported in GNU sed 4.x+).

For more on sed:
http://sed.sourceforge.net/

HTH

Peter S Tillier
"Who needs perl when you can write dc, sokoban,
arkanoid and an unlambda interpreter in sed?"


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019