# Compare variable got from location with set of strings

**URL:** <https://www.ruby-forum.com/t/compare-variable-got-from-location-with-set-of-strings/236654>\
**Category:** NGINX\
**Created:** [September 23, 2013, 12:04pm UTC](https://www.ruby-forum.com/t/compare-variable-got-from-location-with-set-of-strings/236654 "2013-09-23T12:04:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [September 23, 2013, 12:04pm UTC](https://www.ruby-forum.com/t/compare-variable-got-from-location-with-set-of-strings/236654/1 "2013-09-23T12:04:14Z")

</div>

Hello,

I have some location in configuration like this:  
location ~ /([A-z]+\_[A-z0-9]+) {  
… do something (got $1) …  
}

And i need to compare this ‘$1’ with a set of strings. How can i do  
this?

Thanks!

---

<div class="post-metadata">

**Author:** ![Vil\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/43a26b/32.png) [@Vil\_S](https://www.ruby-forum.com/u/Vil_S)\
**Post date:** [September 24, 2013, 1:15am UTC](https://www.ruby-forum.com/t/compare-variable-got-from-location-with-set-of-strings/236654/2 "2013-09-24T01:15:33Z")

</div>

On 23 September 2013 11:03, Vil S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello,
> 
> I have some location in configuration like this:  
> location ~ /([A-z]+\_[A-z0-9]+) {  
> … do something (got $1) …  
> }
> 
> And i need to compare this ‘$1’ with a set of strings. How can i do this?

Use a named capture in the location line and the resulting variable  
won’t get clobbered like a $1 would.

HTH,  
Jonathan
