Ngoc Pham
Ngoc Pham

Reputation: 1458

Url django with phone number

i trying match url in django with phone number. First character must is '+' or '0', and all after is number only. I try like this

url(r'^verification/(?P<phone_number>[\+|0][0-9]+)/$', views.VerificationView.as_view(),name='verification')

but this not work. I tried change to [\+0-9] it match '+' but it can in any position. Can you show me what wrong? Thanks so much

Upvotes: 1

Views: 228

Answers (1)

ruddra
ruddra

Reputation: 51998

The following url should work:

url(r'^verification/(?P<phone_number>[+,0][0-9]+)/$', views.VerificationView.as_view(),name='verification')

It will accept both numbers starting with + or 0. Testing reference: https://regexr.com/4cpud.

Upvotes: 1

Related Questions