0
I’m trying to rename files using regex in python, with only one standard works:
def new_string(pattern):
text = pattern.group().lower()
renturn "{}_{}".format(text[0], text[1])
regex = re.compile(r"[a-z][A-Z]")
for x in files:
print(regex.sub(new_string, x))
But I also want to replace other standards:
r"[a-zA-Z][0-9]"
How to find the two patterns instead of one?
I found the solution using |
– Matheus Silva Pinto
You can answer your own question by describing the solution in detail, to help others who have the same problem in the future.
– luislhl
yes, the correct answer is using the "|" regular expression operator. Now you have the option to write an answer to your own question (including an example, etc...), so that your question can help others in the future.
– jsbueno