Hello I have the following two strings
txt = '/path/to/photo/file.jpg'
txt = '/path/to/photo/file_crXXX.jpg'
in the second string, XXX is a long variable path with information in the name because that is processed.
I want to extract the name 'file' in both path
In order to this, I tried the following code
re.search(".*/(.*)\.jpg", txt).group(1)
re.search(".*/(.*)_cr.*", txt).group(1)
But when I try to combine in one expression with the following code
re.search(".*/(.*)(_cr.*)|(\.jpg)*", txt).group(1)
re.search(".*/(.*)(\.jpg)|(_cr.*)", txt).group(1)
Doesn't work properly, so how can I do this?
Thanks