No need to use expensive regex
, if barely needed then try-
Use r'(/)(?=$)'
pattern that is capture last /
and replace with r''
i.e. blank character.
>>>re.sub(r'(/)(?=$)',r'','/home/ro/A_Python_Scripts/flask-auto/myDirectory/scarlett Johanson/1448543562.17.jpg/')
>>>'/home/ro/A_Python_Scripts/flask-auto/myDirectory/scarlett Johanson/1448543562.17.jpg'