[Tutor] RE Silliness

bob gailer bgailer at gmail.com
Mon Jan 5 18:19:32 CET 2009


Omer wrote:
> Bob, I tried your way.
>
> >>> import re
> >>> urlMask = r"http://[\w\Q./\?=\R]+(<br>)?"
> >>> text=u"Not working 
> example<br>http://this.is.a/url?header=null<br>And another 
> line<br>http://and.another.url"
> >>> re.findall(urlMask,text)
> [u'<br>', u'']

Oops I failed to notice you were using findall. Kent explained it.

Another way to fix it is to make (<br>) a non-group: (?:<br>)

-- 
Bob Gailer
Chapel Hill NC 
919-636-4239



More information about the Tutor mailing list