src/Text.php
public function replaceByRegex(Regex $search, Text $replace): Text {
    return $search->replace($this, $replace);
  }
public function replaceByRegex(Regex $search, Text $replace): Text {
    return $search->replace($this, $replace);
  }
Replaces parts of this Text object based on a search and replace via a regex

@param  Regex  $search   The regex to match
@param  Text   $replace  The text with which to replace the found text

@return  Text  A new Text object containing this Text object, with all search text replaced