Date: Thu, 23 Mar 2006 09:07:19 +0300 From: "Andrew Pantyukhin" <infofarmer@gmail.com> To: "Gary Kline" <kline@tao.thought.org> Cc: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: perl regex help request... . Message-ID: <cb5206420603222207q62b2e60es1fccc2bd67ea7891@mail.gmail.com> In-Reply-To: <20060322231823.GA23486@thought.org> References: <20060322231823.GA23486@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 3/23/06, Gary Kline <kline@tao.thought.org> 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
> <A NAME=3D"NN"> NN xyz </A> 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):
>
> <A NAME=3D"14">14, DEWEY AND TUFTS, *Ethics*, pp 345-7, § 4 =
</A>
>
> with the $1 capturing the 14 and $2 capturing the rest?
>
> The entire s//g expr would be::
>
> s/{(\d+)}(.+)/<A NAME=3D"$1> $1 $2 </A>
>
> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?cb5206420603222207q62b2e60es1fccc2bd67ea7891>
