use regex to search the page one time to get two types of Information

iMath redstone-cold at 163.com
Sat Aug 20 05:39:08 EDT 2016


On Friday, August 19, 2016 at 9:45:08 PM UTC+8, Friedrich Rentsch wrote:
> On 08/19/2016 09:02 AM, iMath wrote:
> > I need to use regex to search two types of Information within a web page, while it seems  searching the page two times rather than one is much time consuming , is it possible to search the page one time to get two or more types of Information?
> 
>  >>> r = re.compile ('page|Information|time')
>  >>> r.findall ( (your post) )
> ['Information', 'page', 'page', 'time', 'time', 'page', 'time', 
> 'Information']
> 
> Does that look right?
> 
> Frederic

I found starting the second search from the first match.endpos does reduce the time consuming, with less time consuming than your solution ,thanks anyway !



More information about the Python-list mailing list