a regular expression problem

L

lookon

I want to use django to dispatch url.
The url is like /test/Google/6,and my patten is r'^/test/(?P<q>\b\W+
\b)/(?P<h>\d+)$'.
It works when the string is English(like Google), but fails when the
string is in foreign language.

Can anyone tell me the righ regular expression?

Thank you!
 
B

Bruno Desthuilliers

lookon a écrit :
I want to use django to dispatch url.
The url is like /test/Google/6,and my patten is r'^/test/(?P<q>\b\W+
\b)/(?P<h>\d+)$'.
It works when the string is English(like Google), but fails when the
string is in foreign language.

Care to give an exemple of url that fails ?

Anyway, if you want to match just *anything* in that path segment, you
can try:

r'^/test/(?P<q>.+?)/(?P<h>\d+)$'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,775
Messages
2,569,601
Members
45,182
Latest member
alexanderrm

Latest Threads

Top