Python Django中匹配url的正则表达式

Python Django中匹配url的正则表达式,python,django,regex,Python,Django,Regex,我正在尝试将此url与django/python中的regexp(旧的liferay url)匹配 但我无法解码文件名 这是我使用的regexp: documents/(?P<repo>[0-9]{5,10})/(?P<folder>[0-9]{5,10})/(?P<filename>[])/(?P<uuid>[\w-]+) documents/(?P[0-9]{5,10})/(?P[0-9]{5,10})/(?P[])/(?P[\w-]+)

我正在尝试将此url与django/python中的regexp(旧的liferay url)匹配

但我无法解码文件名

这是我使用的regexp:

documents/(?P<repo>[0-9]{5,10})/(?P<folder>[0-9]{5,10})/(?P<filename>[])/(?P<uuid>[\w-]+)
documents/(?P[0-9]{5,10})/(?P[0-9]{5,10})/(?P[])/(?P[\w-]+)
这是Pythex

只需使用

documents/(?P<repo>\d+)/(?P<folder>\d+)/(?P<filename>[^/]+)/(?P<uuid>[^/]+)
documents/(?P\d+)/(?P\d+)/(?P[^/]+)/(?P[^/]+)

解释

--------------------------------------------------------------------------------
  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)
--------------------------------------------------------------------------------
文件/'documents/'
--------------------------------------------------------------------------------
(?P组和捕捉到(?P=回购):
--------------------------------------------------------------------------------
\d+数字(0-9)(1次或多次(匹配
尽可能多的钱)
--------------------------------------------------------------------------------
)期末(?P=回购)
--------------------------------------------------------------------------------
/                        '/'
--------------------------------------------------------------------------------
(?P组并捕获到(?P=文件夹):
--------------------------------------------------------------------------------
\d+数字(0-9)(1次或多次(匹配
尽可能多的钱)
--------------------------------------------------------------------------------
)结束(?P=文件夹)
--------------------------------------------------------------------------------
/                        '/'
--------------------------------------------------------------------------------
(?P组并捕获到(?P=文件名):
--------------------------------------------------------------------------------
[^/]+除“/”(1个或多个)以外的任何字符
次数(与最大金额匹配)
(可能的)
--------------------------------------------------------------------------------
)结束(?P=文件名)
--------------------------------------------------------------------------------
/                        '/'
--------------------------------------------------------------------------------
(?P组并捕获到(?P=uuid):
--------------------------------------------------------------------------------
[^/]+除“/”(1个或多个)以外的任何字符
次数(与最大金额匹配)
(可能的)
--------------------------------------------------------------------------------
)结束(?P=uuid)

谢谢!太完美了!
--------------------------------------------------------------------------------
  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)