re grouping question
CyberGuest
rickymz at yahoo.com
Thu May 3 22:44:31 EDT 2001
sr=re.compile(r'( - \w+\n)+')
Michael Esveldt wrote:
> I've got the following code:
>
> s = """some text
> - foo
> - bar
> - fnord
> test..."""
> list_re = re.compile(r'( - .+\n)+')
> print list_re.search(s).groups()
>
> which produces, (' - fnord\n',) when what I was expecting was matching
> all the lines. What I'm really looking for is something more like (' -
> foo\n - bar\n - fnord\n',) or (even better) (' - foo\n', ' - bar\n', ' -
> fnord\n').
>
> I tried this in perl and got the same results, in tcl it matches what I
> want, but who knows about tcl.
>
> Thanks,
> Michael
More information about the Python-list
mailing list