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     public function isActive()

    {

        $pattern = preg_quote(config('statamic.cp.route'), '#').'/'.$this->active;



        return preg_match('#'.$pattern.'#', request()->decodedPath()) === 1;

    }
<?php     protected function filterTestLike($item, $like)

    {

        $pattern = '/^'.str_replace(['%', '_'], ['.*', '.'], preg_quote($like, '/')).'$/im';



        if (is_array($item)) {

            $item = json_encode($item);
<?php             $loopedText = $associative ? $parses->first() : $parses->implode('');




            $text = $this->preg_replace('/'.preg_quote($match[0][0], '/').'/m', addcslashes($loopedText, '\\$'), $text, 1);

        }



        return $text;
<?php                 $parameters = $this->parseVariablesInsideParameters($parameters, $data);

            }



            if ($this->preg_match('/{{\s*\/'.preg_quote($name, '/').'\s*}}/m', $text_subselection, $match, PREG_OFFSET_CAPTURE) && ! $selfClosed) {

                $content = substr($text_subselection, 0, $match[0][1]);

                $tag .= $content.$match[0][0];
<?php                 $tag .= $content.$match[0][0];




                $nested_regex = '/{{\s*('.preg_quote($name, '/').')(\s.*?)}}(.*?){{\s*\/\1\s*}}/ms';

                if ($this->preg_match($nested_regex, $content.$match[0][0], $nested_matches)) {

                    $nested_content = $this->preg_replace('/{{\s*\/'.preg_quote($name, '/').'\s*}}/m', '', $nested_matches[0]);

                    $content = $this->createExtraction('nested_tag_pair', $nested_content, $nested_content, $content);
<?php                 $nested_regex = '/{{\s*('.preg_quote($name, '/').')(\s.*?)}}(.*?){{\s*\/\1\s*}}/ms';

                if ($this->preg_match($nested_regex, $content.$match[0][0], $nested_matches)) {

                    $nested_content = $this->preg_replace('/{{\s*\/'.preg_quote($name, '/').'\s*}}/m', '', $nested_matches[0]);

                    $content = $this->createExtraction('nested_tag_pair', $nested_content, $nested_content, $content);

                }

            }
<?php                 $replacement = $this->valueToLiteral($replacement);

            }



            $text = $this->preg_replace('/'.preg_quote($tag, '/').'/m', addcslashes($replacement, '\\$'), $text, 1);

            $text = $this->injectExtractions($text, 'nested_tag_pair');

        }
<?php             $conditional .= ': ?>';



            $text = $this->preg_replace('/'.preg_quote($match[0], '/').'/m', addcslashes($conditional, '\\$'), $text, 1);

        }



        $text = $this->preg_replace($this->conditionalElseRegex, '<?php else: ?>', $text);