public function replaceFirst($search, $replace)
    {
        if ($search == '') {
            return $this;
        }

        $position = strpos($this->string, $search);

        if ($position === false) {
            return $this;
        }

        $resultString = substr_replace($this->string, $replace, $position, strlen($search));

        return new static($resultString);
    }
public function replaceFirst($search, $replace)
    {
        if ($search == '') {
            return $this;
        }

        $position = strpos($this->string, $search);

        if ($position === false) {
            return $this;
        }

        $resultString = substr_replace($this->string, $replace, $position, strlen($search));

        return new static($resultString);
    }
public function replaceFirst ( $ search , $ replace ) { if ( $ search == '' ) { return $ this ; } $ position = strpos ( $ this -> string , $ search ) ; if ( $ position === false ) { return $ this ; } $ resultString = substr_replace ( $ this -> string , $ replace , $ position , strlen ( $ search ) ) ; return new static ( $ resultString ) ; }
Replace the first occurrence of a string.

@param $search
@param $replace

@return \Spatie\String\Str
Replace the first occurrence of a string .