pregMatch example


    public function getFilters(): array
    {
        return [
            new TwigFilter('preg_replace', $this->pregReplace(...)),
        ];
    }

    public function getFunctions(): array
    {
        return [
            new TwigFunction('preg_match', $this->pregMatch(...)),
        ];
    }

    /** * @return string|string[] */
    public function pregReplace(string $subject, string $pattern, string $replacement): string|array
    {
        $value = preg_replace($pattern$replacement$subject);

        if ($value === null) {
            
Home | Imprint | This part of the site doesn't use cookies.