src/services/RedirectsService.php
private function _isRedirectRegex ($uri)
	{
		// If the URI doesn't look like a regex...
		if (preg_match('/\/(.*)\/([g|m|i|x|X|s|u|U|A|J|D]+)/m', $uri) === 0)
		{
			// Escape all non-escaped `?` not inside parentheses
			$i = preg_match_all(
				'/(?<!\\\\)\?(?![^(]*\))/',
				$uri,
				$matches,
				PREG_OFFSET_CAPTURE
			);

			while ($i--)
			{
				$x   = $matches[0][$i][1];
				$uri = substr_replace($uri, '\?', $x, 1);
			}

			// Escape all non-escaped `/` not inside parentheses
			$i = preg_match_all(
				'/(?<!\\\\)\/(?![^(]*\))/',
				$uri,
				$matches,
				PREG_OFFSET_CAPTURE
			);

			while ($i--)
			{
				$x   = $matches[0][$i][1];
				$uri = substr_replace($uri, '\/', $x, 1);
			}
		}

		// Check if contains a valid regex
		if (@preg_match($uri, null) === false)
			$uri = '/^' . $uri . '$/i';

		if (@preg_match($uri, null) !== false)
			return $uri;

		return false;
	}
private function _isRedirectRegex ($uri)
	{
		// If the URI doesn't look like a regex...
		if (preg_match('/\/(.*)\/([g|m|i|x|X|s|u|U|A|J|D]+)/m', $uri) === 0)
		{
			// Escape all non-escaped `?` not inside parentheses
			$i = preg_match_all(
				'/(?<!\\\\)\?(?![^(]*\))/',
				$uri,
				$matches,
				PREG_OFFSET_CAPTURE
			);

			while ($i--)
			{
				$x   = $matches[0][$i][1];
				$uri = substr_replace($uri, '\?', $x, 1);
			}

			// Escape all non-escaped `/` not inside parentheses
			$i = preg_match_all(
				'/(?<!\\\\)\/(?![^(]*\))/',
				$uri,
				$matches,
				PREG_OFFSET_CAPTURE
			);

			while ($i--)
			{
				$x   = $matches[0][$i][1];
				$uri = substr_replace($uri, '\/', $x, 1);
			}
		}

		// Check if contains a valid regex
		if (@preg_match($uri, null) === false)
			$uri = '/^' . $uri . '$/i';

		if (@preg_match($uri, null) !== false)
			return $uri;

		return false;
	}
Checks if the redirect URI is a regex

@param string $uri

@return bool|mixed|string