http://xxx/abc[x-z]/image(9|10|11).png
http://xxx/abcx/image9.png
http://xxx/abcy/image9.png
http://xxx/abcz/image9.png
http://xxx/abcx/image10.png
http://xxx/abcy/image10.png
http://xxx/abcz/image10.png
http://xxx/abcx/image11.png
http://xxx/abcy/image11.png
http://xxx/abcz/image11.png
sample.py
import sre_yield
if __name__ == '__main__':
regex = r'http://xxx/abc[x-z]/image(9|10|11)\.png'
urllist = list(sre_yield.AllStrings(regex))
print(urllist)
Execution result
['http://xxx/abcx/image9.png', 'http://xxx/abcy/image9.png', 'http://xxx/abcz/image9.png', 'http://xxx/abcx/image10.png', 'http://xxx/abcy/image10.png', 'http://xxx/abcz/image10.png', 'http://xxx/abcx/image11.png', 'http://xxx/abcy/image11.png', 'http://xxx/abcz/image11.png']
Recommended Posts