diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index fa8d8e6580..bc631d54f3 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -741,7 +741,7 @@ public function cloneBlock($blockname, $clones = 1, $replace = true, $indexVaria $xmlBlock = null; $matches = array(); preg_match( - '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', + '/()(.*?)()/is', $this->tempDocumentMainPart, $matches ); @@ -761,7 +761,7 @@ public function cloneBlock($blockname, $clones = 1, $replace = true, $indexVaria if ($replace) { $this->tempDocumentMainPart = str_replace( - $matches[2] . $matches[3] . $matches[4], + $matches[1] . $matches[3] . $matches[4], implode('', $cloned), $this->tempDocumentMainPart ); @@ -781,14 +781,14 @@ public function replaceBlock($blockname, $replacement) { $matches = array(); preg_match( - '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', + '/()(.*?)()/is', $this->tempDocumentMainPart, $matches ); if (isset($matches[3])) { $this->tempDocumentMainPart = str_replace( - $matches[2] . $matches[3] . $matches[4], + $matches[1] . $matches[3] . $matches[4], $replacement, $this->tempDocumentMainPart ); diff --git a/tests/PhpWord/Reader/Word2007/ElementTest.php b/tests/PhpWord/Reader/Word2007/ElementTest.php index d5db6be826..08b72418ac 100644 --- a/tests/PhpWord/Reader/Word2007/ElementTest.php +++ b/tests/PhpWord/Reader/Word2007/ElementTest.php @@ -64,7 +64,7 @@ public function testReadAlternateContent() $text = $elements[0]; $this->assertEquals('Test node value', trim($text->getElement(0)->getText())); } - + /** * Test reading of textbreak */