Help with regex and optional substring in search string

Timur Tabi timur.tabi at
Wed Oct 14 16:59:13 CEST 2009

On Oct 14, 9:51 am, Timur Tabi <timur.t... at> wrote:
> I'm having trouble creating a regex pattern that matches a string that
> has an optional substring in it.  What I'm looking for is a pattern
> that matches both of these strings:
> Subject: [PATCH 08/18] This is the patch name
> Subject: This is the patch name
> What I want is to extract the "This is the patch name".  I tried this:
> m ='Subject:\s*(\[[\w\s]*\])*(.*)', x)

Never mind ... I figured it out.  The middle block should have been [\w

More information about the Python-list mailing list