I've got the following regex function:

```
for(var key in args) {
  var regex = new RegExp('{' + key + '[^}]*}', 'g');
  pattern = pattern.replace(regex, args[key]);
}

```

This makes sure when `args` looks like: 

```
var args: {
  name: 'test',
  id: '12' 
}

```

And 

```
pattern = "{name}/{id:[0-9]}"

```

When this function is called, `pattern` will change to `test/12` 

But when `pattern` look like `{name[a-z]}/{name2[0-9]}`, `name2` gets the same value as `name` when my `args` look like: 

```
var args: {
  name: 'test',
  name2: '12'
}

```

How can I edit my code to make `pattern` look like `test/12`?