regex, repeating group

Steven Scott progoth at progoth.com
Fri May 30 15:32:18 EDT 2003


say I'm working with this:
  str = """body body body
-><-
Meeting Info
From:you
Attendees:me
Date:now
ID:0"""

I have this regular expression to get the data after colons, which I'm using 
in re.search:

regex = r'-><-\n.+?\n(?:.+?:(.*?)\n?){4}$'

my problem is that this (when I call .groups()) only returns the last datum, 
('0',).  if I make the outer group non-grouping I only get ('ID:0', 
'0')....still not any of the other lines of data.

if I take out the {4} and copy and paste the whole group so it's listed 4 
times, everything works right:
('you', 'me', 'now', '0')

so is there a way I can get this to work without pasting a copy for each match?

-- 
Steven Scott [progoth at progoth.com]
Don't give up fighting, 'til nothing else stands in your way..Don't
give up talking, until there's nothing left to say....But no matter
what you do, don't ever compromise what you believe.   --The Ataris





More information about the Python-list mailing list