title: replacing "=" of encoded string in qt c++
body: <p>I have a Text Which is being encoded using base64 
  For example I have a String </p>
  
  <pre><code>string = "Hello"
  </code></pre>
  
  <p>It is encoded </p>
  
  <pre><code>Encoded string is :"SGVsbG9XQ1Q="
  </code></pre>
  
  <p>and then prepend the string with "||" (2-Pipe Character)</p>
  
  <p>Now problem is I want to replace all <code>=</code> in that encoded string with <code>|</code> (one pipe) only at end of strings not in middle of any string  </p>
  
  <p>How will I replace all <code>=</code> only at end of the String with <code>|</code> in qt c++?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;QCoreApplication&gt;
  #include &lt;QString&gt;
  #include &lt;QDebug&gt;
  #include &lt;QByteArray&gt;
  
  QString base64_encode(QString string);
  int main(int argc, char *argv[])
  {
      QCoreApplication a(argc, argv);
  
      QString srcString = "HelloWCT";
      QString encodedString = base64_encode(srcString);
  
      qDebug() &lt;&lt; "Encoded string is" &lt;&lt; encodedString;
      return a.exec();
   }
  
   QString base64_encode(QString string){
   QByteArray ba;
   ba = ba.append(string);
   ba = ba.toBase64();
   ba = ba.prepend("||");
   return(ba);
  }
  </code></pre>
  
  <p>How to apply my replacing logic only at end of string?can anybody help me with the logic?</p>
  
  <p>I have logic but dont know how to apply it?</p>
  
  <p>Logic is: it will start checking from end of string if there is "=" it will replace it with "|" and it wil gain check if there exist another "=" before the last equal to it will again replace and then if before second "=" if there is another character it will stop replacing  how can we do this ?</p>