Re: [Tutor] Issues with regex escaping on \{

2009-07-30 Thread gpo
Thanks! The ? got rid of the greediness! vince spicer wrote: On Wed, Jul 29, 2009 at 11:35 AM, gpo goodpotat...@yahoo.com wrote: your grouping (.+) appears to be greedy, you can make it non-greedy with a question mark EX: pUserID=re.compile('UserID:\s+{(.+?)}',re.I) Vince

[Tutor] Issues with regex escaping on \{

2009-07-29 Thread gpo
My regex is being run in both Python v2.6 and v3.1 For this example, I'll give one line. This lines will be read out of log files. I'm trying to get the GUID for the User ID to query a database with it, so I'd like a sub match. Here is the code - import re line = 'Checking

Re: [Tutor] Issues with regex escaping on \{

2009-07-29 Thread vince spicer
On Wed, Jul 29, 2009 at 11:35 AM, gpo goodpotat...@yahoo.com wrote: My regex is being run in both Python v2.6 and v3.1 For this example, I'll give one line. This lines will be read out of log files. I'm trying to get the GUID for the User ID to query a database with it, so I'd like a sub

Re: [Tutor] Issues with regex escaping on \{

2009-07-29 Thread Bill Campbell
On Wed, Jul 29, 2009, vince spicer wrote: On Wed, Jul 29, 2009 at 11:35 AM, gpo goodpotat...@yahoo.com wrote: My regex is being run in both Python v2.6 and v3.1 For this example, I'll give one line. This lines will be read out of log files. I'm trying to get the GUID for the User ID to

Re: [Tutor] Issues with regex escaping on \{

2009-07-29 Thread wesley chun
in addition to the good advice from vince (watch out for greediness regardless of what you're looking for) and bill (use raw strings... regexes are one of their primary use cases!), another thing that may help with the greediness issue are the character sets you're using inside to match with. for