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
signature.asc
Description: PGP signature