- Joined
- Jan 24, 2006
- Location
- South Dakota
Given the following code:
What is the best way to return both the "([\d\.]+[02468])" and "([\d\.]+)". What I am ultimately trying to do is set both of the "([\d\.]+" sections of the line to the same. So if I pass in "stable_version" or "unstable_version" each instanace of "([\d\.]+" gets set to the same value
Thanks for any pointers
EDIT: here is what I am currently running with:
Code:
import re
stable_version = "([\d\.]+[02468])"
line = "http://ftp.gnome.org/pub/gnome/sources/yelp/([\d\.]+[02468])/yelp-([\d\.]+)\.tar\.xz"
print re.findall(r'\[\\d\\.\]\+*.*/', line)
What is the best way to return both the "([\d\.]+[02468])" and "([\d\.]+)". What I am ultimately trying to do is set both of the "([\d\.]+" sections of the line to the same. So if I pass in "stable_version" or "unstable_version" each instanace of "([\d\.]+" gets set to the same value
Thanks for any pointers
EDIT: here is what I am currently running with:
Code:
uscan_version = "([\d\.]+[02468])"
uscan_directories = ["/some/path/yelp-3.10.1"]
for directory in uscan_directories:
os.chdir(directory)
print(("Beginning uscan of %s" % directory))
for line in fileinput.FileInput(watch_file, inplace=True):
if "http" in line:
joined_line = "-".join(os.path.basename(directory).split("-")[:-1])
replace_this_regex = re.findall(r'%s/(.*?)/' % joined_line, line)[0].replace("'\\'", "'\'")
print(line.replace(replace_this_regex, uscan_version).rstrip()),
else:
print(line),