I am new to this forum. Glad it exists. Thanks for that. I have a
production website that uses nginx 0.8.53 reverse proxy in front of
apache. I actually had little problem setting that up, but this simple
regex is giving me a headache.
I am fairly new to regex, so maybe this is something simple. What I want
to get is the first letter of first captured word. I am able to pull
the entire word with (.*) for $1, but not the first letter only.
Brilliant! It works perfectly. Do you have any idea why the curly braces
didn’t work and also where I can learn when to use a location in a
location? Thank you so much!
Brilliant! It works perfectly. Do you have any idea why the curly
braces didn’t work and also where I can learn when to use a location
in a location? Thank you so much!
Note: for curly braces ('{' and '}'), as they are used both in
regexes and for block control, to avoid conflicts, regexes with
curly braces are to be enclosed with double quotes (or single
quotes). For example, to rewrite URLs like
rewrite "/photos/([0-9] {2})([0-9] {2})([0-9] {2})"
Of course it won’t. The regex above will only match url like this:
/manufacturers/a/something
and not:
/manufacturers/asdfgh/something
Because /(.{1})/ will only match (and capture) one character between
two slashes (e.g. /u/, /b/) while /(.).*/ will match (and capture)
first character of word between two slashes (e.g. /unix/, /books/).