Fix replaceCaptures() to work with more than 9 captures
Currently, the for loop iterates from 1...n, which is an issue,
if n > 9. Luckily, this so far was never an issue, since we
typically have only one or two captures in dynamic context rules.
Additionally, the helper function to escape the regexp is
removed in favor of QRegularExpression::escape().
Differential Revision: https://phabricator.kde.org/D6858