这个django正则表达式是什么意思? `?P` [英] what does this django regex mean? `?P`

查看:407
本文介绍了这个django正则表达式是什么意思? `?P`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的urls.py中有以下正则表达式,我想知道这是什么意思。特别是正则表达式的(?P< category_slug> 部分。



r'^ / p>

解决方案

(?P< name> regex) - 圆括号对它们之间的正则表达式进行分组,它们捕获由其内的正则表达式匹配的文本,可以由锐利该名称可能包含字母和数字。



复制粘贴: http://www.regular-expressions.info/refext.html


I have the following regex in my urls.py and I'd like to know what it means. Specifically the (?P<category_slug> portion of the regex.

r'^category/(?P<category_slug>[-\w]+)/$

解决方案

(?P<name>regex) - Round brackets group the regex between them. They capture the text matched by the regex inside them that can be referenced by the name between the sharp brackets. The name may consist of letters and digits.

Copy paste from: http://www.regular-expressions.info/refext.html

这篇关于这个django正则表达式是什么意思? `?P`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆