What you're trying to get from the match is not clear - maybe you just want the full string?
((?:(?:[cC]:)|//home)[^\.]+\.[A-Za-z]{3})
A dot (.
) will match (close to) everything. If you want to compare and contrast against the string .
, you should escape it with \.
.
Test runs:
>>> print re.match("((?:(?:[cC]:)|//home)[^\.]+\.[A-Za-z]{3})", "//home/user/web/image.png").groups()
('//home/user/web/image.png',)
>>> print re.match("((?:(?:[cC]:)|//home)[^\.]+\.[A-Za-z]{3})", "C:/users/path/image.png").groups()
('C:/users/path/image.png',)
And one for the usual Windows path syntax:
>>> print re.match("((?:(?:[cC]:)|//home)[^\.]+\.[A-Za-z]{3})", "C:\users\path\image.png").groups()
('C:\\users\\path\\image.png',)
If there's a need to support .jpeg
, increase the max allowed occurrences for the extensions from {3}
to {3,4}
.