src/Str.php
public function replace(string $search, string $replacement): self
    {
        if (!$this->contains($search)) {
            return $this;
        }

        return $this
            ->split($search)
            ->join($replacement);
    }
public function replace(string $search, string $replacement): self
    {
        if (!$this->contains($search)) {
            return $this;
        }

        return $this
            ->split($search)
            ->join($replacement);
    }
public function replace ( string $ search , string $ replacement ) : self { if ( ! $ this -> contains ( $ search ) ) { return $ this ; } return $ this -> split ( $ search ) -> join ( $ replacement ) ; }
Replace all occurences of the search string with the replacement one

@param string $search
@param string $replacement

@return self
Replace all occurences of the search string with the replacement one