Question: In Zend Framework 2 I want to pass an array of parameters from one action to another within the same controller which I did in ZF1 in the following manner:

```
$this->_helper->redirector->gotoSimple('foo', null, null, $params);

```

and in fooAction:

```
$params = $this->_request->getParams();

```

In ZF2, trying the various answers I have seen here on SO, I came up with the following:

```
$this->redirect()->toRoute('home/default', array(
            'controller' => 'client',
            'action' => 'foo',
            'param' => 'bar'),
        array('param' => 'bar'));

```

(trying both the $params and $options arguments of toRoute())

and in fooAction:

```
$param = $this->getEvent()->getRouteMatch()->getParams();

```

or

```
$param = $this->params()->fromRoute());

```

None works for me. Is there a simple way to achieve what I want (passing parameters with a redirect) or should I go the route of using a container, session or even global variables?

Answer: 
`+?` is a [**lazy** operator](http://www.regular-expressions.info/repeat.html#lazy), meaning that it tries to match as few characters as possible before going further.

Normally, operators try to match as much as possible, from left to right, and if the rest of the expression fails, they *backtrack* to a shorter match. Lazy operators do the other way around: try to match as few characters as possible, and if the remaining expressions don't match, expand the current match.

So, the first part, `(\b\w+?)`, will try to match 1 character (`g`), and see if what follows is an `es` or an `s`, and a word boundary. Since that fails, it adds one more letter, and so on, until the first part matches `glass`. In this phase, the second part does match the remaining `es`.

If you replace that with a non-lazy, [greedy operator](http://www.regular-expressions.info/repeat.html#greedy), as in `(\b\w+)(?=(?:es|s)\b)`, it will go the other way around. First, it assigns `glasses` to the first part, `(\b\w+)`, but fails to match an additional `e` or `es`, so it backtracks to `glasse`, which succeeds in matching the remaining `s` with the second part of the expression.
It isn't a question of precedence; the regex engine simply takes the first match it finds. You're using a reluctant quantifier, so after consuming the first character, `(\b\w+?)` hands off to `(?=(?:es|s)\b)` to see if it can match. That fails, so `(\b\w+?)` consumes another character and hands off again, and so on. The first place `(?=(?:es|s)\b)` can match is after `glass`, so that's what you match.

If you had used a normal, greedy quantifier, it would have been different. `(\b\w+)` would initially consume the whole string, but `(?=(?:es|s)\b)` would fail. So it would back off, giving back the last `s`. The lookahead would then successfully match the `s`, so you would end up matching `glasse`.

By the way, there are no conditionals in your regex. I'm not sure what you're referring to exactly: the lookahead--`(?=(?:es|s)\b)`--or the alternation--`(?:es|s)`--but a conditional is [something else entirely](http://www.regular-expressions.info/conditional.html).