preg_quote

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Quote regular expression characters
<?php preg_quote(string $str, ?string $delimiter = null): string
<?php         $cwd = rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;



        return preg_replace('/^' . preg_quote($cwd, '/') . '/', '', $file);

    }

}
<?php     protected static function prefixOpeningDirective($found, $template)

    {

        $foundEscaped = preg_quote($found, '/');



        $prefix = '<!--[if BLOCK]><![endif]-->';
<?php         $prefix = '<!--[if BLOCK]><![endif]-->';



        $prefixEscaped = preg_quote($prefix);




        $foundWithPrefix = addcslashes($prefix.$found, '$\\');
<?php         $found = rtrim($found);



        $foundEscaped = preg_quote($found, '/');



        $suffix = '<!--[if ENDBLOCK]><![endif]-->';
<?php         $suffix = '<!--[if ENDBLOCK]><![endif]-->';



        $suffixEscaped = preg_quote($suffix);




        $foundWithSuffix = addcslashes($found.$suffix, '$\\');
<?php                     yield $tag;

                }

            } while (((string) $cursor) !== $defaultCursorValue);

        })->map(fn (string $tagKey) => Str::match('/^'.preg_quote($prefix, '/').'tag:(.*):entries$/', $tagKey));

    }
<?php         }



        return $this->getGuarded() == ['*'] ||

               ! empty(preg_grep('/^'.preg_quote($key, '/').'$/i', $this->getGuarded())) ||

               ! $this->isGuardableColumn($key);

    }
<?php             $type = strtolower($result->type);



            $collation = preg_match(

                '/\b'.preg_quote($result->name).'\b[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:default|check|as)\s*(?:\(.*?\))?[^,]*)*collate\s+["\'`]?(\w+)/i',

                $sql,

                $matches

            ) === 1 ? strtolower($matches[1]) : null;
<?php             $isGenerated = in_array($result->extra, [2, 3]);



            $expression = $isGenerated && preg_match(

                '/\b'.preg_quote($result->name).'\b[^,]+\s+as\s+\(((?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*)\)/i',

                $sql,

                $matches

            ) === 1 ? $matches[1] : null;
<?php     protected function keyReplacementPattern()

    {

        $escaped = preg_quote('='.$this->laravel['config']['app.key'], '/');



        return "/^APP_KEY{$escaped}/m";

    }
<?php         return preg_replace(

            vsprintf('/use %s;[\r\n]+use %s;/', [

                preg_quote($namespacedModel, '/'),

                preg_quote($namespacedModel, '/'),

            ]),

            "use {$namespacedModel};",
<?php         return preg_replace(

            vsprintf('/use %s;[\r\n]+use %s;/', [

                preg_quote($namespacedModel, '/'),

                preg_quote($namespacedModel, '/'),

            ]),

            "use {$namespacedModel};",

            $stub
<?php         $split = explode('/', $actual);



        return isset($split[1]) && preg_match('#'.preg_quote($split[0], '#').'/.+\+'.preg_quote($split[1], '#').'#', $type);

    }
<?php     protected function allSubdomainsOfApplicationUrl()

    {

        if ($host = parse_url($this->app['config']->get('app.url'), PHP_URL_HOST)) {

            return '^(.+\.)?'.preg_quote($host).'$';

        }

    }
<?php         $radius = $options['radius'] ?? 100;

        $omission = $options['omission'] ?? '...';



        preg_match('/^(.*?)('.preg_quote((string) $phrase, '/').')(.*)$/iu', (string) $text, $matches);



        if (empty($matches)) {

            return null;