public function get_regex($key, $pattern, $default = null)
    {
        $filtered = \filter_var(
            $this->get($key),
            FILTER_VALIDATE_REGEXP,
            [
                "options" => [
                    "regexp" => $pattern,
                ],
            ]
        );

        if ($filtered === false) {
            return $default;
        }

        return $filtered;
    }
public function get_regex($key, $pattern, $default = null)
    {
        $filtered = \filter_var(
            $this->get($key),
            FILTER_VALIDATE_REGEXP,
            [
                "options" => [
                    "regexp" => $pattern,
                ],
            ]
        );

        if ($filtered === false) {
            return $default;
        }

        return $filtered;
    }
public function get_regex ( $ key , $ pattern , $ default = null ) { $ filtered = \ filter_var ( $ this -> get ( $ key ) , FILTER_VALIDATE_REGEXP , [ "options" => [ "regexp" => $ pattern , ] , ] ) ; if ( $ filtered === false ) { return $ default ; } return $ filtered ; }
Only return a value if it matches the supplied regex pattern.

Otherwise the $default is returned.

@param  string $key     Item key to fetch.
@param  string $pattern A regex pattern to check against.
@param  mixed  $default Default value if the key is not present.
@return mixed
Only return a value if it matches the supplied regex pattern .