Need help parsing with pyparsing...

Paul McGuire ptmcg at austin.rr.com
Mon Oct 22 12:35:04 EDT 2007


On Oct 22, 4:18 am, "Just Another Victim of the Ambient Morality"
<ihates... at hotmail.com> wrote:
>     I'm trying to parse with pyparsing but the grammar I'm using is somewhat
> unorthodox.  I need to be able to parse something like the following:
>
> UPPER CASE WORDS And Title Like Words
>
>     ...into two sentences:
>
> UPPER CASE WORDS
> And Title Like Words
>
>     I'm finding this surprisingly hard to do.  The problem is that pyparsing
> implicitly assumes whitespace are ignorable characters and is (perhaps
> necessarily) greedy with its term matching.  All attempts to do the
> described parsing either fails to parse or incorrectly parses so:
>
> UPPER CASE WORDS A
> nd Title Like Words
>
>     Frankly, I'm stuck.  I don't know how to parse this grammar with
> pyparsing.
>     Does anyone know how to accomplish what I'm trying to do?
>     Thank you...

By the way, are these possible data lines?:

A Line With No Upper Case Words
A LINE WITH NO TITLE CASE WORDS
SOME UPPER CASE WORDS A Title That Begins With A One Letter Word

-- Paul




More information about the Python-list mailing list