The problem come from your first (.+)
which is greedy and grab all he can, probably until the last #
of the subject string.
You can try with this pattern:
const char *scriptRegexFullNameReplace = "$1\"$2\"#\"$3\"$4";
scriptRegexFullName.assign("(\\p{L}+,\\d+,\\d+,\\d+\\s+script\\s+)([^#]+)#(\\S+)(\\s+\\d+,\\{)");
Notices:
- the escape of the curly bracket is probably uneeded, try to remove it.
p{L}
stand for any unicode letter but you can try replace it by[^,]
if it is a problem- You can replace all
+
by++
for more performances (no backtracks allowed) - No need to capture the sharp to replace it by itself, it is the reason why the pattern has only four capturing groups
- instead of using
(.+?)
(the dot with a lazy quantifier), it is better for performances to use a greedy quantifier with a reduced character class:[^#]
that will match all characters until the first#