Reputation: 717
This is the continuation of question
How to use python regular expression inside if... else... statement?
My Python script:
import wget
if windowsbit == x86:
url = 'http://test.com/test_windows_2_56_30-STEST.exe'
filename = wget.download(url)
else:
url = 'http://test.com/test_windows-x64_2_56_30-STEST.exe'
filename = wget.download(url)
url contains only two files. one is for 32 bit and another is for 64 bit. I mean always the old files with be deleted and only new files will be there in that url. Always 32 bit file will start with test_windows and ends with STEST.exe . And 64bit file will start with test_windows-x64 and ends with STEST.exe .
Could anyone guide me on writing wildcard or regexp?
Upvotes: 0
Views: 58
Reputation: 180441
If you want to check the url and it is always in that format, you just need to check if it startswith "test_windows-x64"
after splitting:
if url.rsplit("/", 1)[1].startswith("test_windows-x64"):
# do whatever
else:
# it is 32 bit
If you really need to check the ending:
base = url.rsplit(None,1)[1]
if base.startswith("test_windows-x64") and base.endswith("STEST.exe")
Upvotes: 1