mybb/mybb — pull request #1384 by medbenji (2014-09-04 22:22:29+00:00)
Title: Added a $limit option to find_replace_templatesets

Some plugins need to set a limitation on the number of possible replacements in a template, imagine you want to add a script right after some "", and your template contains two or more "", if you don't specify a limitation, you will get your string inserted twice. A more serious issue happened to me when I tried to replace a whole template (using /.*/s), the replacement got inserted twice, because preg_replace considered even the empty string as a match, I replaced it with /.+/s (one character at least) as a workaround, but it's still not what I should do, because I DO want to allow empty templates to be replaced too, along the non-empty templates to be replaced also, but I want to limit that to ONE remplacement only.