S
S
Sergey Pugovkin2018-03-24 22:46:11
Nginx
Sergey Pugovkin, 2018-03-24 22:46:11

How to specify character length in location nginx regular expression?

Why when specifying the length in a regular expression:

location ~ ^/qwerty/[0-9a-f]{2}/([0-9a-f]{32})([0-9]{10})([0-9]+)\.php$ {
...
}

An error pops up: unknown directive "2}/([0-9a-f]"
??
There is no error when replacing with "+":
location ~ ^/qwerty/[0-9a-f]+/([0-9a-f]+)([0-9]+)([0-9]+)\.php$ {
...
}

But how to specify the length of characters?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pugovkin, 2018-03-24
@Driver86

The expression must be enclosed in quotation marks. Curly braces are not only used in regular expressions.

location ~ '^/qwerty/[0-9a-f]{2}/([0-9a-f]{32})([0-9]{10})([0-9]+)\.php$' {
...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question