Not quite right either, even if it didn't have the non matched open
parenthesis after the carat, since it would match "foo-bar--1234.html".

Perhaps '^(?:[a-zA-Z0-9]+-)+(?P<nid>\d+).html$'

(?:...) is a non-capturing group, if you're not familiar with it.

Bill

On Thu, Feb 21, 2013 at 3:05 PM, Arnold Krille <arn...@arnoldarts.de> wrote:

> On Thu, 21 Feb 2013 10:46:05 -0800 (PST) Aswani Kumar
> <aswin.1...@gmail.com> wrote:
> > my url pattern
> >
> > [a-zA-Z0-9]-(?P<nid>\d+).html
> >
> > urls will be like
> >
> > news-in-finland-yesterday-festival-3456.html
> >
> > i want 3456 which is news id.
> >
> > the regex is correct but not working if i keep it in urls.
> > url('^[a-zA-Z0-9]-(?P<nid>\d+).html$', 'tempa'),
>
> Whether your pattern is correct or depends on what you want to achieve:
>  - if you want to match a single digit or letter followed by a dash and
>    a  number uf digits for the id, then your pattern is correct.
>  - if you want your pattern to macht the url you have given, then its
>    not correct.
>
> You want something like this (untested):
>
> url(r'^([a-zA-Z0-9\-]+-(?P<nid>\d+).html$', 'tempa')
>
> And that only matches lower- and upper-case letters, numbers and
> dashes. If you want to allow any non-ascii characters you might want
> something different in that first parantheses.
>
> Have fun,
>
> Arnold
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to