Beispiel #1
0
 public function testReplace()
 {
     $pattern = '#replace this#';
     $regex = new Regex($pattern);
     $text = new Text('This is replace this test');
     $replaced = $regex->replace($text, new Text('a'));
     $this->assertSame('This is a test', $replaced->raw);
 }
Beispiel #2
0
 /**
  * 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
  */
 public function replaceByRegex(Regex $search, Text $replace)
 {
     return $search->replace($this, $replace);
 }