Let's say I have a tuple like

(r'.*:https?://q.q.mysite.org.* (?P<xx>.*)', ...)
It will match both qqq.mysite.org and q.q.mysite.org

(r'.*:https?://q\.q\.mysite\.org.* (?P<xx>.*)', ...)
matches only q.q.mysite.org  (which is intended)

('.*:https?://q\\.q\\.mysite\\.org.* (?P<xx>.*)', ...)
Yes, I know, without "r" it's necessary to double the "\"

Therefore I think the second line would be the best solution.

Ok, I'll open an issue.


2013/8/8 Jonathan Lundell <[email protected]>

> On 7 Aug 2013, at 3:19 PM, Niphlod <[email protected]> wrote:
>
> ok for the book, but routes.py is ok.
> if you notice, there's the r in front of the string.... that r means
> "string literal", as in "literally this string", so \n, \t, etc don't get
> interpreted and quoting isn't necessary (because it gets interpreted as a
> byte string and not a string)
> Actually, while working with regexes, it's quite handy to have r at
> hand....as you noticed the syntax gets increasingly crispy if you choose to
> not use string literals.
> This is explained in detail on http://docs.python.org/2/library/re.html
>
>
> Still need to escape dots, though.
>
> And the extra parens in routes.example.py look wrong.
>
>
> On Thursday, August 8, 2013 12:09:50 AM UTC+2, LightDot wrote:
>>
>> Best thing to do would be to open an issue on Google code and either
>> attach a patch or make a pull request on Github.
>>
>> Forum posts can get overlooked and/or forgotten...
>>
>> Regards,
>> Ales
>>
>> On Wednesday, August 7, 2013 3:17:01 PM UTC+2, mweissen wrote:
>>>
>>> About routes.py
>>>
>>> I have tried to use routes.py. After some hours I have found errors in
>>> the book and in routes.example.py:
>>>
>>> ------------------------------**------------------------------**
>>> ----------
>>>
>>> In the book, chapter "URL rewrite":
>>>
>>> The general syntax for routes is more complex than the simple examples
>>> we have seen so far. Here is a more general and representative example:
>>>
>>> routes_in = (
>>>  ('140.191.\d+.\d+:https?://**www.web2py.com:post /(?P<any>.*).php',
>>>   '/test/default/index?vars=\g<**any>'),
>>> )
>>>
>>> It maps http or https POST requests (note lower case "post") to host
>>> www.web2py.com from a remote IP matching the regular expression
>>>
>>> '140.191.\d+.\d+'
>>>
>>> The first part is a regular expression. I think, it should read:
>>>
>>>
>>> The general syntax for routes is more complex than the simple examples
>>> we have seen so far. Here is a more general and representative example:
>>> routes_in = ( ('140\.191\.\d+\.\d+:https?://**www\.web2py\.com:post
>>> /(?P<any>.*).php', '/test/default/index?vars=\g<**any>'), )
>>>
>>> It maps http or https POST requests (note lower case "post") to host
>>> www.web2py.com from a remote IP matching the regular expression
>>> '140\.191\.\d+\.\d+'
>>>
>>
>
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to