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
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
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
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
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