Vorrei rimuovere il carattere " dalla mia stringa, la quale può contenerlo solo come carattere iniziale e/o finale:
Come posso fare utilizzando i metodi standard o magari la libreria boost::string?codice:"aaaa" ---> aaaa
Grazie.
Vorrei rimuovere il carattere " dalla mia stringa, la quale può contenerlo solo come carattere iniziale e/o finale:
Come posso fare utilizzando i metodi standard o magari la libreria boost::string?codice:"aaaa" ---> aaaa
Grazie.
Fracty - The Fractal Generator
If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks.
Effettivamente ho risolto con
o:codice:boost::trim_if(str, is_any_of("\""));
codice:boost::erase_all(str, "\"");
Fracty - The Fractal Generator
If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks.
Puoi usare std::remove(), che in realtà sposta il carattere da togliere in fondo alla stringa e restituisce l'iteratore corrispondente a quel carattere.
A questo punto puoi riassegnare l'intervallo con .assign() o effettuare un .resize sulla stessa stringa.
codice:string a ="\"aaaa\""; // std::string::iterator it per il C++98 auto it = std::remove(a.begin(),a.end(),'\"'); a.assign(a.begin(),it); oppure a.resize(std::distance(a.begin(),it));
This code and information is provided "as is" without warranty of any kind, either expressed
or implied, including but not limited to the implied warranties of merchantability and/or
fitness for a particular purpose.
Grazie![]()
Fracty - The Fractal Generator
If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks.