[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: regexp for "anything except the combination .} "



On 5/27/07, Russell L. Harris <rlharris@oplink.net> wrote:
I am trying to write a regular expression which searches for the
following string:

    \footnote{xxxxx.}

where xxxx is any character, including newline.  I wish to capture the
entire string in a match variable.  Thus far, I have
written:

    /(\\footnote(.*([^\.][^}]))/s

Do you want to match to the end of file, or are you assuming there's
always a ".}" at the end?  If the latter, then I'd think one of the
following would work (depending on how much you want to capture:

/\\footnote(.*)\.}/s # grab the text in the footnote, without the trailing "."
/(\\footnote.*\.})/s # grab the whole latex command
/(\\footnote.*)\.}/s # grab the start of the command and everything in
the arg except the trailing "."

In any case, you'll run into problems with text like this:

\footnote{We can match a bunch of footnotes, but \emph{this is too
                difficult for a one-line regexp.}  C'est la vie.}

--
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com
http://36pints.blogspot.com



Reply to: