Forum


Replies: 5   Views: 709
Searchandreplace only firstmatch
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 27-10-2022 - 13:31

Hello,

Template methods such as replaceVariableByText needs to use template placeholders; this is specific symbols wrapping words to set template placeholders ($VAR_1$, ${VAR_MY} ... ). On https://www.phpdocx.com/documentation/practical/working-with-templates is detailed how to work with template documents with phpdocx.

The searchAndReplace method allows doing text replacements without using template placeholders, but as explained in our previous reply this method doesn't include the firstMatch option. The searchAndReplace method can't be replaced with replaceVariableByText; each method has its own purpose and requirements. In the case of replaceVariableByText, template placeholders must be used to do replacements.

Regards.