Python - regex to match url with mongo object id -


i trying write regex matches url of following format:

/api/v1/users/<mongo_object_id>/submissions 

where example of mongo_object_id 556b352f87d4693546d31185. have cooked following pattern, not seems work.

/api/v1/users\\/(?=[a-f\\d]{24}$)(\\d+[a-f]|[a-f]+\\d)\\/submissions 

any appreciated.

this (considering 24 hex chars), using raw keyword before string no need escape double slashes:

r'\/api\/v1\/users\/([a-f\d]{24})\/submissions' 

python console:

>>> re.findall(r'\/api\/v1\/users\/([a-f\d]{24})\/submissions','/api/v1/users/556b352f87d4693546d31185/submissions') ['556b352f87d4693546d31185'] 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -