File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,9 @@ public function __construct($strFilename)
81
81
*
82
82
* @param mixed $search
83
83
* @param mixed $replace
84
+ * @param integer $limit
84
85
*/
85
- public function setValue ($ search , $ replace )
86
+ public function setValue ($ search , $ replace, $ limit = - 1 )
86
87
{
87
88
$ pattern = '|\$\{([^\}]+)\}|U ' ;
88
89
preg_match_all ($ pattern , $ this ->_documentXML , $ matches );
@@ -102,7 +103,12 @@ public function setValue($search, $replace)
102
103
}
103
104
}
104
105
105
- $ this ->_documentXML = str_replace ($ search , $ replace , $ this ->_documentXML );
106
+ $ regExpDelim = '/ ' ;
107
+ $ escapedSearch = preg_quote ($ search , $ regExpDelim );
108
+ $ this ->_documentXML = preg_replace ("{$ regExpDelim }{$ escapedSearch }{$ regExpDelim }u " ,
109
+ $ replace ,
110
+ $ this ->_documentXML ,
111
+ $ limit );
106
112
}
107
113
108
114
/**
You can’t perform that action at this time.
0 commit comments