Help with regex and optional substring in search string
Timur Tabi
timur.tabi at gmail.com
Wed Oct 14 10:59:13 EDT 2009
On Oct 14, 9:51 am, Timur Tabi <timur.t... at gmail.com> 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 = re.search('Subject:\s*(\[[\w\s]*\])*(.*)', x)
Never mind ... I figured it out. The middle block should have been [\w
\s/]*
More information about the Python-list
mailing list