Re: Using Regular Expressions to Parse SQL

2008-02-05 Thread MRAB
On Feb 5, 6:18 pm, [EMAIL PROTECTED] wrote: > Firstly, thanks to those who posted. > > I just do not understand how the non-greedy operator works. > > Using the following code: > > import re > > s = "qry_Lookup.desc = CSS_Rpt1.desc AND qry_Lookup.lcdu1 = > CSS_Rpt1.lcdu" > > pat = "(.+=)+?(.+)"

Re: Using Regular Expressions to Parse SQL

2008-02-05 Thread ct60
Firstly, thanks to those who posted. I just do not understand how the non-greedy operator works. Using the following code: import re s = "qry_Lookup.desc = CSS_Rpt1.desc AND qry_Lookup.lcdu1 = CSS_Rpt1.lcdu" pat = "(.+=)+?(.+)" m = re.match(pat, s) if m is None: print "No Match" else:

Re: Using Regular Expressions to Parse SQL

2008-02-05 Thread Paul McGuire
On Feb 5, 8:31 am, [EMAIL PROTECTED] wrote: > Hello again - > > I do not seem to be able to get a handle on non-greedy pattern > matching. > Regexps wont cut it when you have to parse nested ()'s in a logical expression. Here is a pyparsing solution. For your specific application, you will need

RE: Using Regular Expressions to Parse SQL

2008-02-05 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] > Sent: Tuesday, February 05, 2008 9:31 AM > To: python-list@python.org > Subject: Using Regular Expressions to Parse SQL > > > My pattern does no

Using Regular Expressions to Parse SQL

2008-02-05 Thread ct60
Hello again - I do not seem to be able to get a handle on non-greedy pattern matching. I am trying to parse the following - note that there are no line breaks in the string: " FROM ((qry_Scores_Lookup1 INNER JOIN CSS_Rpt1 ON (qry_Scores_Lookup1.desc = CSS_Rpt1.desc) AND (qry_Scores_Lookup1.lastc