public function replaceFirst($pattern, $replacement): self
    {
        Assert::typeOf(['string', __CLASS__], $pattern, $replacement);
        $result = preg_replace($pattern, $replacement, $this->data, 1);

        return new static($result ?: $this->data, $this->encoding);
    }