<?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[replace the character &#x27; with &#x5C;&#x27; in the QString.]]></title><description><![CDATA[<p dir="auto">Dear Qt guys,<br />
May be this is really a silly question but i am still could not find the solutions.<br />
I have string there i have to replace some charaters.</p>
<pre><code>QString = Book + ' '+ Pen;
</code></pre>
<p dir="auto">I have to replace the " ' "with the characters  " \ ' "</p>
<p dir="auto">I tried with lots of code</p>
<pre><code>formulaString.replace("'", "\'");
formulaString.replace("\'", "\\'");
formulaString.replace("\'", "/\'");
</code></pre>
<p dir="auto">but nothing worked.Please suggest me any solution if you have<br />
TIA</p>
]]></description><link>https://forum.qt.io/topic/94161/replace-the-character-with-in-the-qstring</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 04:42:32 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/94161.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Aug 2018 10:26:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to replace the character &#x27; with &#x5C;&#x27; in the QString. on Sun, 29 Mar 2020 07:39:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/akash1">@<bdi>Akash1</bdi></a><br />
Its</p>
<pre><code>formulaString.replace("\'", "\\\'");
</code></pre>
<p dir="auto">The odd part was that since \ is special too, it must also be escaped.</p>
<p dir="auto">or</p>
<pre><code>formulaString.replace(R"(')", R"(\')");
</code></pre>
<p dir="auto">which use the new raw strings and is good if many chars that need escaping.</p>
]]></description><link>https://forum.qt.io/post/585317</link><guid isPermaLink="true">https://forum.qt.io/post/585317</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 29 Mar 2020 07:39:41 GMT</pubDate></item><item><title><![CDATA[Reply to replace the character &#x27; with &#x5C;&#x27; in the QString. on Sun, 29 Mar 2020 04:11:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sebastian">@<bdi>Sebastian</bdi></a> , could you please post your resolution here? I need this. Thanks in advanced,</p>
]]></description><link>https://forum.qt.io/post/585311</link><guid isPermaLink="true">https://forum.qt.io/post/585311</guid><dc:creator><![CDATA[Akash1]]></dc:creator><pubDate>Sun, 29 Mar 2020 04:11:26 GMT</pubDate></item><item><title><![CDATA[Reply to replace the character &#x27; with &#x5C;&#x27; in the QString. on Mon, 03 Sep 2018 11:58:36 GMT]]></title><description><![CDATA[<p dir="auto">Thanks guys i got the the solution.Thanks for your help.Qt provide the functionality what i was looking for.</p>
]]></description><link>https://forum.qt.io/post/479460</link><guid isPermaLink="true">https://forum.qt.io/post/479460</guid><dc:creator><![CDATA[Sebastian]]></dc:creator><pubDate>Mon, 03 Sep 2018 11:58:36 GMT</pubDate></item><item><title><![CDATA[Reply to replace the character &#x27; with &#x5C;&#x27; in the QString. on Thu, 30 Aug 2018 10:55:11 GMT]]></title><description><![CDATA[<p dir="auto">Since we all agreed that escape sequences are a pain in the 🍑 C++11 introduced <a href="https://solarianprogrammer.com/2011/10/16/cpp-11-raw-strings-literals-tutorial/" target="_blank" rel="noopener noreferrer nofollow ugc">raw string literals</a>:</p>
<p dir="auto"><code>formulaString.replace(R"(')", R"(\')");</code></p>
]]></description><link>https://forum.qt.io/post/478874</link><guid isPermaLink="true">https://forum.qt.io/post/478874</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Thu, 30 Aug 2018 10:55:11 GMT</pubDate></item><item><title><![CDATA[Reply to replace the character &#x27; with &#x5C;&#x27; in the QString. on Thu, 30 Aug 2018 10:48:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/koahnig">@<bdi>koahnig</bdi></a> :Thanks for your reply.This i alreday tried.</p>
]]></description><link>https://forum.qt.io/post/478873</link><guid isPermaLink="true">https://forum.qt.io/post/478873</guid><dc:creator><![CDATA[Sebastian]]></dc:creator><pubDate>Thu, 30 Aug 2018 10:48:26 GMT</pubDate></item><item><title><![CDATA[Reply to replace the character &#x27; with &#x5C;&#x27; in the QString. on Thu, 30 Aug 2018 10:43:12 GMT]]></title><description><![CDATA[<p dir="auto">Was just wondering if there is not some help around.</p>
<p dir="auto">Check out <a href="https://doc.qt.io/qt-5/qregularexpression.html#escape" target="_blank" rel="noopener noreferrer nofollow ugc">QRegularExpression::escape</a></p>
]]></description><link>https://forum.qt.io/post/478872</link><guid isPermaLink="true">https://forum.qt.io/post/478872</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Thu, 30 Aug 2018 10:43:12 GMT</pubDate></item><item><title><![CDATA[Reply to replace the character &#x27; with &#x5C;&#x27; in the QString. on Thu, 30 Aug 2018 10:39:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sebastian">@<bdi>Sebastian</bdi></a></p>
<p dir="auto">When you need to have a special character in string you have to prepend with a backslash as you know obviously already. The confusion comes typically because backslash is also such a character.</p>
<pre><code>formulaString.replace("\'", "\\\'");
</code></pre>
<p dir="auto">The examples of [QRegularExpressions](formulaString.replace("'", "\'") and playing a bit may help.</p>
]]></description><link>https://forum.qt.io/post/478871</link><guid isPermaLink="true">https://forum.qt.io/post/478871</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Thu, 30 Aug 2018 10:39:39 GMT</pubDate></item></channel></rss>