Beginner questions
-
Hello guys i wonder if someone could help with some beginner questions:
Q1)
When I use .replace and i don't want to replace the original string, do I need to make a copy of it? or is there an API that doesn't replace the original string?example:
QString str = "a - b"; QString str2 = str.replace(str, "-");this will replace the content of str but I would like it to don't, do I need to make a copy before?
Q2)
I wonder if there's any API to count the number of replacements done on anstr.replace?I was reading the docs of
replacebut I didn't see anycountparameter https://doc.qt.io/qt-6/qstring.htmlDo I need to build mine or maybe use regex match and count the size of the match object?
Q3)
Is possible to check the substring without declaring a string before?QString s = "..."; QString s2 = "100000"; s += s2.mid(0, 6 - (s.length() % 6));to something like
QString s "..."; s += "100000".mid(0, 6 - (s.length() % 6));Q4)
Is it possible to see the content ofQRegularExpressionMatch matchobject in the debugger watch ofVisual Studio? it only shows some pointers. -
Hello guys i wonder if someone could help with some beginner questions:
Q1)
When I use .replace and i don't want to replace the original string, do I need to make a copy of it? or is there an API that doesn't replace the original string?example:
QString str = "a - b"; QString str2 = str.replace(str, "-");this will replace the content of str but I would like it to don't, do I need to make a copy before?
Q2)
I wonder if there's any API to count the number of replacements done on anstr.replace?I was reading the docs of
replacebut I didn't see anycountparameter https://doc.qt.io/qt-6/qstring.htmlDo I need to build mine or maybe use regex match and count the size of the match object?
Q3)
Is possible to check the substring without declaring a string before?QString s = "..."; QString s2 = "100000"; s += s2.mid(0, 6 - (s.length() % 6));to something like
QString s "..."; s += "100000".mid(0, 6 - (s.length() % 6));Q4)
Is it possible to see the content ofQRegularExpressionMatch matchobject in the debugger watch ofVisual Studio? it only shows some pointers.@Cesar said in Beginner questions:
do I need to make a copy before?
Yes, as stated in the documentation it's modifying the object.
Do I need to build mine
Yes you have to do it on your own.
s += "100000".mid(0, 6 - (s.length() % 6));
Apart from a missing usecase - use QLatin1String("100000") or QStringLiteral("100000")
Is it possible to see the content of QRegularExpressionMatch match object in the debugger watch
Yes, it should - see https://wiki.qt.io/IDE_Debug_Helpers