python regular expression is stuck to the original cycle of death

With the following regular expression will cause an infinite loop, analyze the specific reasons behind

import re

url = "http://search.www.gov.cn/search/fw/cateSearch.do?webid=1&category=bmfw&q="

if re.match('^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$', url):
    print 'ok'
else:
    print 'no'

Url for a regular grammar finished

url = "http://search.www.gov.cn/search/fw/cateSearch.do?webid=1&category=bmfw&q="

if re.match('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', url):
    print 'ok'
else:
    print 'no'
Published 16 original articles · won praise 1 · views 298

Guess you like

Origin blog.csdn.net/m0_46232048/article/details/104336042