Forum


Replies: 5   Views: 714
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 phosira  · 27-10-2022 - 12:41

Is searchAndReplace use firstMatch?

or should i use other features?

Posted by admin  · 27-10-2022 - 12:47

Hello,

The firstMatch option is available in many template methods such as replaceVariableByText or replacePlaceholderImage. But the searchAndReplace method doesn't include it.

Regards.

Posted by phosira  · 27-10-2022 - 13:14

How can i use replaceVariableByText like search and replace? 

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.

Posted by peteruser1  · 29-10-2022 - 16:35

Deleted by admin · 30-10-2022 - 08:19

Posted by Almaza211  · 17-11-2022 - 11:54

Deleted by admin · 17-11-2022 - 12:20