PHPOffice/PHPWord — pull request #17 by Esmeraldo (2013-01-10 22:40:19+00:00)
Title: Advanced string replace in setValue in Update src/PHPWord/Template.php

When started using Phpword it saved me a lot of time as i needed to replace a template
in docx using php. I had a minor issue when started using the setValue method. I found
that using Word, the program creates some tags that the str_replace couldn't detect.

I cracked a little bit the function, using some regular expressions in order to:

1. Find the regular expressions commencing with '${' and ending with '}' (in my case i
dropped the $ sign cause i needed to use the $ sign in my word file)
2. With only that string, find and eliminate all the opening tags
3. find and eliminate the closing tags in that string
4. replace the old string (with garbage code) with the cleaned string
5. output the _documentXML
6. this is the piece of code I implemented if anyone is interested

Btw, great job with this tool it saved me a lot of time!

Consulate in the site: http://phpword.codeplex.com/workitem/49