I don't know anything about Qt, but from what I read, QRegExp is pretty limited in what it can do, and things like wildcard characters can be problematic. If possible, use QRegularExpression Class instead. I believe the following would do what you want, but probably not with QRegExp. It would work in Perl-like RegExp engines:
echo\s+["']((?:[^"']|["'](?!\s*>))+)["']
What this does is search for "echo" followed by at least one whitespace, then match either "
or '
(I assume either could be used), followed by anything that is not a quotation mark or anything that is a quotation mark not followed by >
, at least once and as many times as possible, and then it matches the closing quotation mark.
It's important to realize that the regex engine needs some way of distinguishing what is the starting quote and what is the ending. What I've assumed here is that the start quote is always preceded by echo
and the end quote is always followed by >
. You might have to tweak things if those assumptions are incorrect.