bug #10299 [Finder] () is also a valid delimiter (WouterJ)

This PR was merged into the 2.3 branch.

Discussion
----------

[Finder] () is also a valid delimiter

The `Regex` class should also accept `()` as delimiters, as they are valid PREG delimiters: http://3v4l.org/D8v54

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

b7519c7 () is also a valid delimiter
This commit is contained in:
Fabien Potencier 2014-02-20 20:43:52 +01:00
commit 5e665b5c7a

View File

@ -65,7 +65,11 @@ class Regex implements ValueInterface
$start = substr($m[1], 0, 1);
$end = substr($m[1], -1);
if (($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start)) || ($start === '{' && $end === '}')) {
if (
($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
|| ($start === '{' && $end === '}')
|| ($start === '(' && $end === ')')
) {
return new self(substr($m[1], 1, -1), $m[2], $end);
}
}