RE - non-greedy - some greediness - complete greediness

Roman Suzi rnd at onego.ru
Sun Nov 10 08:57:22 EST 2002


On Sun, 10 Nov 2002, Doru-Catalin Togea wrote:

Probably sgrep (Structure GREP) is up to the task. There are Python hook 
into sgrep.

> Hi!
> 
> I am working on a little project where i need REs with a self-defined
> level of greediness.
> 
> I am processing text in a Latex like manner, for those of you who are
> familiar with it.
> 
> I want to be able to recognize Latex-like commands within my text. A
> command starts with a character, say '\' followed by the command's name
> and followed by the text on which the command applies enclosed in curly
> brackets. Examples:
> 
> 	\footnote{some text}
> 	\cite{some referance}
> 	\section{some title}
> 
> Recognizing such patterns and retriving the name of the command and the
> text on which the command applies is not so difficult to achieve. Things
> get complicated though when one encounters nested commands.
> 
> Say I have the following string:
> 
>  "abcd \footnote{efgh \cite{myRef1} ijkl} mnop \footnote{hello there}"
>                                   ^     ^                           ^
>  closing bracket of nested \cite  |     |                           |
>     closing bracket of first \footnote  |                           |
>                                closing bracket of second \footnote  |
 

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -
 





More information about the Python-list mailing list