1

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

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! It's perfect!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.