[Tutor] Regular Expression question

Scott Chapman scott_list@mischko.com
Fri Apr 18 15:21:35 2003


On Friday 18 April 2003 11:46, Jay Dorsey wrote:
> Scott Chapman wrote:
> > Is it possible to make a regular expression that will match:
> > '<html blah>' or '<html>'
> > without having to make it into two complete expressions seperated by a
> > pipe: r'<html[ \t].+?>|<html>'
> >
> > I want it to require a space or tab and at least one character before the
> > closing bracket, after 'html', or just the closing bracket.
> >
> > Scott
>
> How about
>
> '<html([ \t][^>]+)?>'
>

Thanks for the reply.  After seeing these replies, it seems clear that you can 
use the grouping ()'s for more than just capturing a section for output.  I 
think I missed that in the docs I've been reading.  I wonder where all this 
works?  For instance, will it work on either side of a '|'?  I'll have to 
play with this further!

Thanks!
Scott