Score:0

nginx regex location not matching number followed by specific letter

in flag

I tested my regex on a site and it matched, but I can't get it to work in nginx. What am I missing?

I want to find any parameter with string window that has numbers and a d (not h for hour) like:

?window=30d&some-other-arg

and not match:

?window=24h&some-other-arg

pattern that works on https://regex101.com/r/5f6WpI/1

~ window=([^&]*)+d

And nginx location is:

location ~ window=([^&]*)+d {
Richard Smith avatar
jp flag
There is nothing wrong with the regex. But the part of the URL that you are testing is called the query string, which cannot be tested using a `location` or `rewrite` directive. What are you trying to do inside the `{}`s? You may be able to use `if ($arg_window ~ ^(.*)d$) { ... }` instead.
jesse avatar
in flag
Thanks! I have a new question based on this but your answer is correct for what I asked.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.