Regex issue

For some reason, I am unable to take a URI like
example.com/manufacturers/metlox/0?page=13 and change it to
example.com/manufacturers/m

It seems like the curly braces aren’t working. I’ve tried the following
without results:

location ~* /manufacturers/ {

    rewrite "^/manufacturers/(.{1})/(.*)$" 

/manufacturer/directory/$1
redirect;

    }

location ~* /manufacturers/ {

    rewrite "^/manufacturers/([a-z] {1})/(.*)$"

/manufacturer/directory/$1 redirect;

    }

location ~* /manufacturers/ {

    rewrite "^/manufacturers/([a-z]?)/(.*)$" 

/manufacturer/directory/$1
redirect;

    }

I am new to regex, so maybe this is something simple. What I want to get
is
the first letter of first captured word. What I can do is pull the
entire
word with (.*), but not the first letter only.

Any help would be appreciated.

Thanks in advance.

Using nginx 0.8.53 reverse proxy in front of apache

On Wed, Jan 18, 2012 at 11:58 PM, mpratt [email protected] wrote:

For some reason, I am unable to take a URI like
example.com/manufacturers/metlox/0?page=13 and change it to
example.com/manufacturers/m

It seems like the curly braces aren’t working. I’ve tried the following
without results:

/(.{1})/
This will match and capture one character between slashes
Examples:
/a/ -> $1: a
/asd/ -> no match (three characters)

/([a-z]*)/
This one will match and capture one or less letter between slashes
Examples:
/a/ -> $1: a
/asd/ -> no match

/([a-z]?)/
This one is equivalent to /([a-z]*)/

/([a-z] ?)/
This one will match and capture one letter followed by space between
slashes
Examples:
/a/ -> no match
/a / -> $1: " a"
/asd/ -> no match

/(.).*/
This one will match one or more characters between slashes and capture
the first character
/a/ -> $1: a
/a / -> $1: a
/asd/ -> $1: a


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

Sorry, I made mistake

/([a-z] ?)/
This one will match and capture one letter optionally followed by space between
slashes
Examples:
/a/ -> $1: a
/a / -> $1: "a "
/asd/ -> no match


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

Thank you so much. This explanation really helps.

Sorry for the nearly duplicate post. This one came through the mailing
list delayed before I discovered this forum.

Thanks again!

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,221431,221450#msg-221450

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs