Parsing a search string

It's me itsme at yahoo.com
Fri Dec 31 11:39:08 EST 2004


I am right in the middle of doing text parsing so I used your example as a
mental exercise.   :-)

Here's a NDFA for your text:

       b  0 1-9 a-Z ,  . +  -   '   " \n
S0: S0 E   E  S1  E E E S3 E S2  E
S1: T1 E   E  S1  E E E  E  E  E T1
S2: S2 E   E  S2  E E E  E  E T2  E
S3: T3 E   E  S3  E E E  E  E  E T3

and the end-states are:

E: error in text
T1: You have the words: moo, cow
T2: You get "farmer john" (w quotes)
T3: You get zug

Can't gurantee that I did it right - I did it really quick - and it's
*specific* to your text string.

Now just need to hire a programmer to write some clean Python parsing code.
:-)

--
It's me





"Freddie" <lion-freddie at zebra-madcowdisease.giraffe-org> wrote in message
news:kXcBd.1095$ch5.470 at text.usenetserver.com...
> Happy new year! Since I have run out of alcohol, I'll ask a question that
I
> haven't really worked out an answer for yet. Is there an elegant way to
turn
> something like:
>
>  > moo cow "farmer john" -zug
>
> into:
>
> ['moo', 'cow', 'farmer john'], ['zug']
>
> I'm trying to parse a search string so I can use it for SQL WHERE
constraints,
> preferably without horrifying regular expressions. Uhh yeah.
>
>  From 2005,
>    Freddie
>






More information about the Python-list mailing list