From owner-freebsd-questions@FreeBSD.ORG Thu Mar 23 06:07:20 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B8FD16A41F for ; Thu, 23 Mar 2006 06:07:20 +0000 (UTC) (envelope-from infofarmer@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0AC4543D45 for ; Thu, 23 Mar 2006 06:07:19 +0000 (GMT) (envelope-from infofarmer@gmail.com) Received: by zproxy.gmail.com with SMTP id 16so406252nzp for ; Wed, 22 Mar 2006 22:07:19 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uHiZRajJXlhng6fa6gwL5pGxeVtnfLBKUqs1kZMku7Am2pKiMzCb9AZN5yb4Mw4tO5/iL/wBE5lZLIveSDDRtmCwpxtPMQ2yHuAzoCcg0dilWaffzt/AOT1PP+EKZpePRKRdv6Q+Ydl1gZkxdLTMvnjybUBjqeIWfQClxRPsI1M= Received: by 10.37.22.66 with SMTP id z66mr2607130nzi; Wed, 22 Mar 2006 22:07:19 -0800 (PST) Received: by 10.37.22.74 with HTTP; Wed, 22 Mar 2006 22:07:19 -0800 (PST) Message-ID: Date: Thu, 23 Mar 2006 09:07:19 +0300 From: "Andrew Pantyukhin" To: "Gary Kline" In-Reply-To: <20060322231823.GA23486@thought.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20060322231823.GA23486@thought.org> Cc: FreeBSD Mailing List Subject: Re: perl regex help request... . 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, 23 Mar 2006 06:07:20 -0000 On 3/23/06, Gary Kline wrote: > > Guys, > > perlmonks was helpful in explaining that "[[](\d+)[]]" is > what is required to match [NN]. So that will catch the > footnote numbers. I had thought that I would have to do the > NN xyz anchor by hand. Maybe not, if > somebody can clue me in on the perl regex for matching > > "NN plus any/every character following until \n" > > I can't find my regex book, and am not exactly clear if this > will work, but if I go back over my files and insert braces > around each note (at the page bottom) like: > > {14, DEWEY AND TUFTS, *Ethics*, pp 345-7, § 4 } > > would this: > > s/{(\d+)}(.+)/ > > capture the "14" plus the rest on the bracketed line? The > HTML would be (methinks): > > 14, DEWEY AND TUFTS, *Ethics*, pp 345-7, § 4 = > > with the $1 capturing the 14 and $2 capturing the rest? > > The entire s//g expr would be:: > > s/{(\d+)}(.+)/ $1 $2 > > If this is right, I'll be very pleased with myself; else I'm > hoping that somebody can clue me in. {(\d+)} matches {1} or {123} or {89437863896}, but does not match when there's a non-digit (even a whitespace) inside the brackets. If you know that there are no curly braces inside the curly braces you could use just /{(\d+)(.*?)}/ If you're not sure, /{(\d+)(.*)}/ without the /s switch should also work as . will not match a newline.