开发者

Django Regex 'Break Out'?

How do you 'break out' of a regex in Django?

Therefore if one of your URL tokens (after and before a slash /token/) needs 3 digits, a COLON, 3 letters, a 'T' and then 2 digits, a DASH and then 3 digits - how would you do this?

Example:

Accept: 678:bhgT23-789

Reject: 345:fdsM43-432

I've started off with a r'^(?P<somevar>\w{2})/', but don't know where to go from here.

EDIT:

Could you please talk me through any regex you offer i.e. why you used that specific pattern and what each bit means. Thanks开发者_运维技巧.


\d{3}:[a-z]{3}T\d\d-\d{3}

3 digits, colon, 3 letters (if you need uppercase too, make it [a-zA-Z]), a T, two digits, a dash, and then 3 digits.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜