protected function getTemplateRegexPattern()
    {
        $parts = explode('@', $this->template);
        if (count($parts) === 2) {
            $parts[0]    = str_replace('*', self::$nameRegex, $parts[0]);
            $topTLDIndex = strrpos($parts[1], '.');


            if ($topTLDIndex !== FALSE) {
                $secondTLD = substr($parts[1], 0, $topTLDIndex);
                $secondTLD = str_replace('*', self::$domainSecondTLDRegex, $secondTLD);

                $topTLD   = substr($parts[1], $topTLDIndex);
                $topTLD   = str_replace('*', self::$domainTLDRegex, $topTLD);
                $template = $parts[0] . '@' . $secondTLD . $topTLD;
            } else {
                $template = $parts[0] . '@' . $parts[1];
            }
        } else {
            $template = '';
        }

        //$template = str_replace(['.', '+', '-'], ['\.', '\+', '\-'], $template);

        return sprintf('/^%s$/', $template);
    }
protected function getTemplateRegexPattern()
    {
        $parts = explode('@', $this->template);
        if (count($parts) === 2) {
            $parts[0]    = str_replace('*', self::$nameRegex, $parts[0]);
            $topTLDIndex = strrpos($parts[1], '.');


            if ($topTLDIndex !== FALSE) {
                $secondTLD = substr($parts[1], 0, $topTLDIndex);
                $secondTLD = str_replace('*', self::$domainSecondTLDRegex, $secondTLD);

                $topTLD   = substr($parts[1], $topTLDIndex);
                $topTLD   = str_replace('*', self::$domainTLDRegex, $topTLD);
                $template = $parts[0] . '@' . $secondTLD . $topTLD;
            } else {
                $template = $parts[0] . '@' . $parts[1];
            }
        } else {
            $template = '';
        }

        //$template = str_replace(['.', '+', '-'], ['\.', '\+', '\-'], $template);

        return sprintf('/^%s$/', $template);
    }
protected function getTemplateRegexPattern ( ) { $ parts = explode ( '@' , $ this -> template ) ; if ( count ( $ parts ) === 2 ) { $ parts [ 0 ] = str_replace ( '*' , self :: $ nameRegex , $ parts [ 0 ] ) ; $ topTLDIndex = strrpos ( $ parts [ 1 ] , '.' ) ; if ( $ topTLDIndex !== FALSE ) { $ secondTLD = substr ( $ parts [ 1 ] , 0 , $ topTLDIndex ) ; $ secondTLD = str_replace ( '*' , self :: $ domainSecondTLDRegex , $ secondTLD ) ; $ topTLD = substr ( $ parts [ 1 ] , $ topTLDIndex ) ; $ topTLD = str_replace ( '*' , self :: $ domainTLDRegex , $ topTLD ) ; $ template = $ parts [ 0 ] . '@' . $ secondTLD . $ topTLD ; } else { $ template = $ parts [ 0 ] . '@' . $ parts [ 1 ] ; } } else { $ template = '' ; } //$template = str_replace(['.', '+', '-'], ['\.', '\+', '\-'], $template); return sprintf ( '/^%s$/' , $ template ) ; }
Returns the regular expression for an email template.

@return string
Returns the regular expression for an email template .