protected function fixUnnamedCaptures($regexp)
	{
		$keys = [];
		foreach ($this->references['anywhere'] as $key)
		{
			$capture = $this->captures[$key];
			if (!$key || isset($capture['name']))
			{
				continue;
			}
			// Give the capture a name if it's used as URL or it's not a passthrough
			if (isset($this->references['asUrl'][$key]) || !isset($capture['passthrough']))
			{
				$keys[] = $key;
			}
		}

		// Alter the original regexp to inject the subpatterns' names. The position is equal to the
		// subpattern's position plus 2, to account for the delimiter at the start of the regexp and
		// the opening parenthesis of the subpattern. Also, we need to process them in reverse order
		// so that replacements don't change the position of subsequent subpatterns
		rsort($keys);
		foreach ($keys as $key)
		{
			$name   = '_' . $key;
			$pos    = $this->captures[$key]['pos'];
			$regexp = substr_replace($regexp, "?'" . $name . "'", 2 + $pos, 0);
			$this->captures[$key]['name'] = $name;
		}

		return $regexp;
	}
protected function fixUnnamedCaptures($regexp)
	{
		$keys = [];
		foreach ($this->references['anywhere'] as $key)
		{
			$capture = $this->captures[$key];
			if (!$key || isset($capture['name']))
			{
				continue;
			}
			// Give the capture a name if it's used as URL or it's not a passthrough
			if (isset($this->references['asUrl'][$key]) || !isset($capture['passthrough']))
			{
				$keys[] = $key;
			}
		}

		// Alter the original regexp to inject the subpatterns' names. The position is equal to the
		// subpattern's position plus 2, to account for the delimiter at the start of the regexp and
		// the opening parenthesis of the subpattern. Also, we need to process them in reverse order
		// so that replacements don't change the position of subsequent subpatterns
		rsort($keys);
		foreach ($keys as $key)
		{
			$name   = '_' . $key;
			$pos    = $this->captures[$key]['pos'];
			$regexp = substr_replace($regexp, "?'" . $name . "'", 2 + $pos, 0);
			$this->captures[$key]['name'] = $name;
		}

		return $regexp;
	}
protected function fixUnnamedCaptures ( $ regexp ) { $ keys = [ ] ; foreach ( $ this -> references [ 'anywhere' ] as $ key ) { $ capture = $ this -> captures [ $ key ] ; if ( ! $ key || isset ( $ capture [ 'name' ] ) ) { continue ; } // Give the capture a name if it's used as URL or it's not a passthrough if ( isset ( $ this -> references [ 'asUrl' ] [ $ key ] ) || ! isset ( $ capture [ 'passthrough' ] ) ) { $ keys [ ] = $ key ; } } // Alter the original regexp to inject the subpatterns' names. The position is equal to the // subpattern's position plus 2, to account for the delimiter at the start of the regexp and // the opening parenthesis of the subpattern. Also, we need to process them in reverse order // so that replacements don't change the position of subsequent subpatterns rsort ( $ keys ) ; foreach ( $ keys as $ key ) { $ name = '_' . $ key ; $ pos = $ this -> captures [ $ key ] [ 'pos' ] ; $ regexp = substr_replace ( $ regexp , "?'" . $ name . "'" , 2 + $ pos , 0 ) ; $ this -> captures [ $ key ] [ 'name' ] = $ name ; } return $ regexp ; }
Give a name to unnamed captures that are referenced in current replacement

@param  string $regexp Original regexp
@return string         Modified regexp
Give a name to unnamed captures that are referenced in current replacement