Reputation: 755
I'm trying to match this url with a regexp in django/python (old liferay urls)
http://127.0.0.1:8080/documents/34105/35593/prova+(1)+(1).jpg/da459266-ab36-faf1-726d-fc989385b0bd
but I cannot decode the filename...
This is the regexp that I use:
documents/(?P<repo>[0-9]{5,10})/(?P<folder>[0-9]{5,10})/(?P<filename>[])/(?P<uuid>[\w-]+)
This is the Pythex link
Upvotes: 1
Views: 181
Reputation: 18611
Just use
documents/(?P<repo>\d+)/(?P<folder>\d+)/(?P<filename>[^/]+)/(?P<uuid>[^/]+)
See proof.
Explanation
--------------------------------------------------------------------------------
documents/ 'documents/'
--------------------------------------------------------------------------------
(?P<repo> group and capture to (?P=repo):
--------------------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
--------------------------------------------------------------------------------
) end of (?P=repo)
--------------------------------------------------------------------------------
/ '/'
--------------------------------------------------------------------------------
(?P<folder> group and capture to (?P=folder):
--------------------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
--------------------------------------------------------------------------------
) end of (?P=folder)
--------------------------------------------------------------------------------
/ '/'
--------------------------------------------------------------------------------
(?P<filename> group and capture to (?P=filename):
--------------------------------------------------------------------------------
[^/]+ any character except: '/' (1 or more
times (matching the most amount
possible))
--------------------------------------------------------------------------------
) end of (?P=filename)
--------------------------------------------------------------------------------
/ '/'
--------------------------------------------------------------------------------
(?P<uuid> group and capture to (?P=uuid):
--------------------------------------------------------------------------------
[^/]+ any character except: '/' (1 or more
times (matching the most amount
possible))
--------------------------------------------------------------------------------
) end of (?P=uuid)
Upvotes: 1