12 namespace Symfony\Component\Finder\Expression;
64 if (preg_match(
'/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
65 $start = substr($m[1], 0, 1);
66 $end = substr($m[1], -1);
69 ($start === $end && !preg_match(
'/[*?[:alnum:] \\\\]/', $start))
70 || ($start ===
'{' && $end ===
'}')
71 || ($start ===
'(' && $end ===
')')
73 return new self(substr($m[1], 1, -1), $m[2], $end);
77 throw new \InvalidArgumentException(
'Given expression is not a regex.');
87 if (null !== $delimiter) {
109 return self::BOUNDARY
110 .$this->renderPattern()
120 return ($this->startFlag ? self::START_FLAG :
'')
121 .($this->startJoker ? self::JOKER :
'')
122 .str_replace(self::BOUNDARY,
'\\'.self::BOUNDARY, $this->pattern)
123 .($this->endJoker ? self::JOKER :
'')
124 .($this->endFlag ? self::END_FLAG :
'');
148 $this->pattern = $expr.$this->pattern;
158 $this->pattern .= $expr;
170 return false !== strpos($this->options, $option);
181 $this->options .= $option;
194 $this->options = str_replace($option,
'', $this->options);
286 $replace =
function ($subject) use ($replacement) {
287 $subject = $subject[0];
288 $replace = 0 === substr_count($subject,
'\\') % 2;
290 return $replace ? str_replace(
'.', $replacement, $subject) : $subject;
293 $this->pattern = preg_replace_callback(
'~[\\\\]*\\.~', $replace, $this->pattern);
303 if ($this->startFlag = self::START_FLAG === substr(
$pattern, 0, 1)) {
307 if ($this->startJoker = self::JOKER === substr(
$pattern, 0, 2)) {
311 if ($this->endFlag = (self::END_FLAG === substr(
$pattern, -1) && self::ESCAPING !== substr(
$pattern, -2, -1))) {
315 if ($this->endJoker = (self::JOKER === substr(
$pattern, -2) && self::ESCAPING !== substr(
$pattern, -3, -2))) {