<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Beginner questions]]></title><description><![CDATA[<p dir="auto">Hello guys i wonder if someone could help with some beginner questions:</p>
<p dir="auto"><s>Q1)</s><br />
When I use <strong>.replace</strong> 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?</p>
<p dir="auto">example:</p>
<pre><code>QString str = "a - b";
QString str2 =  str.replace(str, "-"); 
</code></pre>
<p dir="auto">this will replace the content of <strong>str</strong> but I would like it to don't, do I need to make a copy before?</p>
<p dir="auto"><s>Q2)</s><br />
I wonder if there's any API to count the number of replacements done on an <code>str.replace</code>?</p>
<p dir="auto">I was reading the docs of <code>replace</code> but I didn't see any <code>count</code> parameter <a href="https://doc.qt.io/qt-6/qstring.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qstring.html</a></p>
<p dir="auto">Do I need to build mine or maybe use regex match and count the size of the match object?</p>
<p dir="auto"><s>Q3)</s><br />
Is possible to check the substring without declaring a string before?</p>
<pre><code>QString s = "...";
QString s2 = "100000";
s += s2.mid(0, 6 - (s.length() % 6));
</code></pre>
<p dir="auto">to something like</p>
<pre><code>QString s "...";
s += "100000".mid(0, 6 - (s.length() % 6));
</code></pre>
<p dir="auto"><s>Q4)</s><br />
Is it possible to see the content of <code>QRegularExpressionMatch match</code> object in the debugger watch of <code>Visual Studio</code>? it only shows some pointers.</p>
]]></description><link>https://forum.qt.io/topic/139171/beginner-questions</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 15:20:10 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139171.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Sep 2022 17:13:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Beginner questions on Thu, 08 Sep 2022 17:18:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cesar">@<bdi>Cesar</bdi></a> said in <a href="/post/727945">Beginner questions</a>:</p>
<blockquote>
<p dir="auto">do I need to make a copy before?</p>
</blockquote>
<p dir="auto">Yes, as stated in the <a href="https://doc.qt.io/qt-6/qstring.html#replace" target="_blank" rel="noopener noreferrer nofollow ugc">documentation</a> it's modifying the object.</p>
<blockquote>
<p dir="auto">Do I need to build mine</p>
</blockquote>
<p dir="auto">Yes you have to do it on your own.</p>
<blockquote>
<p dir="auto">s += "100000".mid(0, 6 - (s.length() % 6));</p>
</blockquote>
<p dir="auto">Apart from a missing usecase - use QLatin1String("100000") or QStringLiteral("100000")</p>
<blockquote>
<p dir="auto">Is it possible to see the content of QRegularExpressionMatch match object in the debugger watch</p>
</blockquote>
<p dir="auto">Yes, it should - see <a href="https://wiki.qt.io/IDE_Debug_Helpers" target="_blank" rel="noopener noreferrer nofollow ugc">https://wiki.qt.io/IDE_Debug_Helpers</a></p>
]]></description><link>https://forum.qt.io/post/727947</link><guid isPermaLink="true">https://forum.qt.io/post/727947</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Thu, 08 Sep 2022 17:18:27 GMT</pubDate></item></channel></rss>