Regex url

MRAB python at mrabarnett.plus.com
Sat Jan 15 21:26:28 EST 2011


On 16/01/2011 01:48, Jean-Francois wrote:
> Hi,
>> I try to match the following url with one regex
>> /hello
> /hello/
> /hello/world
> /hello/world/
>>> world is a variable, I can put toto instead
>The regex is:
 ^/hello(?:/(?:[a-z]+/?)?)$
Its meaning is:
 start of string
 characters "/hello"
 optional:
 character "/"
 optional:
 one or more:
 one of:
 "a" .. "z"
 optional:
 character "/"
 end of string
If it's not what you want, you need to be more specific.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /