473,486 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

a regular expression problem

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!
Oct 10 '08 #1
2 843
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+)$'.

Oct 10 '08 #2
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+
\W should be \w, a typo? :)
\b)/(?P<h>\d+)$'.
It works when the string is English(like Google), but fails when the
string is in foreign language.
Try this:
r'(?u)^/test/(?P<q>\b\w+\b)/(?P<h>\d+)$'
if ?u doesn't work, try ?L.
I'm not sure which encoding a url uses.(locale or unicode? I guess
unicode)
>
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+)$'.
I don't think he wants to match anything :)

Oct 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3132
by: Harry | last post by:
Hi there, does anyone know how I can build a regular expression e.g. for the string.search() function on runtime, depending on the content of variables? Should be something like this: var...
11
5350
by: Dimitris Georgakopuolos | last post by:
Hello, I have a text file that I load up to a string. The text includes certain expression like {firstName} or {userName} that I want to match and then replace with a new expression. However,...
3
3198
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
7
3794
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
9
3337
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use...
3
3313
by: LordHog | last post by:
Hello all, I am attempting to create a small scripting application to be used during testing. I extract the commands from the script file I was going to tokenize the each line as one of the...
25
5128
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
5
3774
by: shawnmkramer | last post by:
Anyone every heard of the Regex.IsMatch and Regex.Match methods just hanging and eventually getting a message "Requested Service not found"? I have the following pattern: ^(?<OrgCity>(+)+),...
1
2090
by: sunil | last post by:
Hi, Am writing one C program for one of my module and facing one problem with the regular expression functions provided by the library libgen.h in solaris. In this library we are having two...
1
1658
by: Shawn B. | last post by:
Greetings, I'm using a custom WebBrowser control: http://www.codeproject.com/KB/miscctrl/csEXWB.aspx When I get the DocumentSource of a web page I browsed, and run a regular expression...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4864
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.