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);
    }
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);
    }
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 ) ; }
Replaces the first substring of this string that matches the given regex pattern with the specified replacement

@param static|string $pattern
@param static|string $replacement
@return static
@throws InvalidArgumentException
@throws TypeError
Replaces the first substring of this string that matches the given regex pattern with the specified replacement