QString replace multiple characters in a single call?
Solved
General and Desktop
-
I want to replace multiple characters in a QString, I can do this:
strContent.replace("\n", " "); strContent.replace("\r", " "); strContent.replace("\t", " ");
What I would like to do is something like this:
QStringList slstBytes; slstBytes << "\n" << "\r" << "\t"; strContent.replace(slstBytes, " ");
I know this isn't possible with the current build, that's just an example.
-
strContent.replace(QRegularExpression("[\\n|\\r|\\t]+"), " ");
-
strContent.replace(QRegularExpression("[\\n|\\r|\\t]+"), " ");
-
@raven-worx said in QString replace multiple characters in a single call?:
strContent.replace(QRegularExpression("[\n|\r|\t]+"), " ");
Thank you, thats exactly what I was looking for.