# Multiple named captures in map regex

**URL:** <https://www.ruby-forum.com/t/multiple-named-captures-in-map-regex/244371>\
**Category:** NGINX\
**Created:** [March 29, 2016, 5:30am UTC](https://www.ruby-forum.com/t/multiple-named-captures-in-map-regex/244371 "2016-03-29T05:30:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [March 29, 2016, 5:30am UTC](https://www.ruby-forum.com/t/multiple-named-captures-in-map-regex/244371/1 "2016-03-29T05:30:59Z")

</div>

Hello,

Is it possible to have more than one named capture in a map regex? When  
I try the following in a map:  
~^/(?.)(?**.) $a$b;**

…I get [emerg] 28486#0: unknown "a$b” variable. I’ve tried "$a$b” and  
"${a}${b}” with no change.

I’m running nginx/1.9.6.

Cole

---

<div class="post-metadata">

**Author:** ![Cole\_Tierney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ce7236/32.png) [@Cole\_Tierney](https://www.ruby-forum.com/u/Cole_Tierney)\
**Post date:** [March 29, 2016, 5:18pm UTC](https://www.ruby-forum.com/t/multiple-named-captures-in-map-regex/244371/2 "2016-03-29T17:18:24Z")

</div>

On Mon, Mar 28, 2016 at 11:30:32PM -0400, Cole Tierney wrote:

Hi there,

> Is it possible to have more than one named capture in a map regex?

In a map regex, yes.

In a “value” part of a map, no.

[Module ngx\_http\_map\_module](http://nginx.org/r/map) says

The resulting value can be a string or another variable

> When I try the following in a map:  
> ~^/(?.)(?**.) $a$b;**

 

You can use $a and $b outside the map; but where you have “$a$b”, you  
must instead have exactly one string or one variable.

 
**## f**
 

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
