No, because he doesn't want it to match the underscore. I think this works:

[-a-zA-Z]

because a hyphen in the first position matches a literal hyphen.
However, to be sure, you can use a backslash

[a-zA-Z\-]

For all regex questions, I highly recommend the Kodos app. It lets you
enter Python regexes and strings and will show you exactly how they
match or don't.

http://kodos.sourceforge.net/

HTH,
Todd

On Jan 1, 2008 10:39 PM,  <[EMAIL PROTECTED]> wrote:
>
> I think that should be an underscore: [a-zA-Z_]
> Owen
>
>
> -----Original Message-----
> From: Greg <[EMAIL PROTECTED]>
> Sent: Tuesday, January 1, 2008 10:36pm
> To: Django users <[email protected]>
> Subject: Re: Can I use a underscore in my url to separate variables?
>
>
> ocgstyles,
> I'm not sure what's going on.  What does the last '-' mean in the
> following code [a-zA-Z-]?  Occasionally I'm going to have the a url
> that is going to have a '-' in the variable.  For example
> http://mysite.com/sprint-phone_cellphone.  So I'm not sure if [a-zA-
> Z-] is going to work.
>
> On Jan 1, 8:51 pm, ocgstyles <[EMAIL PROTECTED]> wrote:
> > worked for me using the following:
> >
> > [urls.py] (i removed the single quotes around the view)
> > from myapp.views import showline
> > (r'^(?P<manufacturer>[a-zA-Z-]+)_(?P<line>[\w-]+)/$', showline),
> >
> > [views.py]
> > def showline(request, manufacturer, line):
> >    return HttpResponse('manu = ' + manufacturer + '<br />line = ' +
> > line)
> >
> > Maybe the error is being generated from somewhere else?
> >
> > On Jan 1, 9:42 pm, Greg <[EMAIL PROTECTED]> wrote:
> >
> > > ocgstyles,
> > > I tried the following however I'm still getting a page not found
> > > error:
> >
> > > (r'^(?P<manufacturer>[a-zA-Z-]+)_(?P<line>[\w-]+)/$', 'showline'),
> >
> > > On Jan 1, 8:23 pm, ocgstyles <[EMAIL PROTECTED]> wrote:
> >
> > > > Hi Greg,
> >
> > > > The problem is that "\w" is consuming the underscore.  Instead of
> > > > using [\w-], use [a-zA-Z-].  The pattern would then look like:
> >
> > > > (r'^(?P<manufacturer>[a-zA-Z-]+)_(?P<line>[\w-]+)/$', 'showline')
> >
> > > > Hope that helps.
> >
> > > > Keith
> >
> > > > On Jan 1, 9:05 pm, Greg <[EMAIL PROTECTED]> wrote:
> >
> > > > > Hello,
> > > > > I orginially had my url like this:
> >
> > > > > (r'^(?P<manufacturer>[\w-]+)/(?P<line>[\w-]+)/$', 'showline')
> >
> > > > > Which would work fine when going to the url 'www.mysite.com/sprint/
> > > > > cellphone/'
> >
> > > > > //////////////
> >
> > > > > However, I want to change my url structure so that all of my pages are
> > > > > as close to the root as possible.  So I replaced my '/' in the url
> > > > > with a '_'.  Like so:
> >
> > > > > (r'^(?P<manufacturer>[\w-]+)_(?P<line>[\w-]+)/$', 'showline')
> >
> > > > > However, I now get a page not found whenever I view the following url
> > > > > 'www.mysite.com/sprint_cellphone/'
> >
> > > > > ////////
> >
> > > > > Can I not replace the / with a _ in my url?
> >
> > > > > Thanks
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to