From owner-freebsd-questions@FreeBSD.ORG Thu Aug 2 13:17:43 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D3CD3106566C for ; Thu, 2 Aug 2012 13:17:43 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com [209.85.215.182]) by mx1.freebsd.org (Postfix) with ESMTP id 64C478FC08 for ; Thu, 2 Aug 2012 13:17:43 +0000 (UTC) Received: by eaak11 with SMTP id k11so1131350eaa.13 for ; Thu, 02 Aug 2012 06:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; bh=OGiIjmOS5WCcTmwXuZ2GBHSNUBmYBuz7hwJnL3BE4lY=; b=sqiQE4cVp4gSglvwkeQP87VVwEllMpC4USyIUYr9r7eEPzTD9QGhHMcDAJJlUjiDgX 1B9fdFjY0899ZIIJBYRr/AX0fIoic4Q51yUraMRHqnaTcUoBft7Lcc8vPA2+QOUw5vgd +ek7DyxpAl7B1lMoCQhTETBePRyIEOruyv2VMhmkyayOGetAtdUpY4/y0gl/6flbM1MB NFe3eQBUFPMzUZSzhwy6JXR2dGFKCVmj4YPzhb4yP9LOK+xR2hCCcuejJPwLnBEk37Y/ tJ8TCmcGqDGQsZRk1m4Zu6lcEKzn0mohPOJQqWxQDecuV57LDTULHgIOKr3iOfH8TYBT ywJw== Received: by 10.14.177.3 with SMTP id c3mr26761118eem.30.1343913462202; Thu, 02 Aug 2012 06:17:42 -0700 (PDT) Received: from gumby.homeunix.com (87-194-105-247.bethere.co.uk. [87.194.105.247]) by mx.google.com with ESMTPS id 8sm17363756eeg.16.2012.08.02.06.17.40 (version=SSLv3 cipher=OTHER); Thu, 02 Aug 2012 06:17:41 -0700 (PDT) Date: Thu, 2 Aug 2012 14:17:38 +0100 From: RW To: freebsd-questions@freebsd.org Message-ID: <20120802141738.62ef1e45@gumby.homeunix.com> In-Reply-To: <743721353.9443.1343906452119.JavaMail.sas1@172.29.249.242> References: <743721353.9443.1343906452119.JavaMail.sas1@172.29.249.242> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.6; amd64-portbld-freebsd8.3) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: buggy awk regex handling? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Aug 2012 13:17:43 -0000 On Thu, 02 Aug 2012 13:20:52 +0200 kaltheat wrote: > > > Hi, > > I tried to replace three letters with three letters by awk using the > sub-routine. I assumed that my regular expression does mean the > following: > > match if three letters of any letter of alphabet occurs anywhere in > input > > $ echo AbC | awk '{sub(/[[:alpha:]]{3}/,"cBa"); print;}' > AbC > > As you can see the result was unexpected. > When I try doing it for at least one letter, it works: > > $ echo AbC | awk '{sub(/[[:alpha:]]+/,"cBa"); print;}' > cBa > ... > What am I doing wrong? > Or is awk buggy? Traditional awk implementations don't support {n}, but I think POSIX implementations should.