samedi 31 octobre 2015

Remove whitespace from string excluding parts between pairs of " and ' C++

So essentially what I want to do is erase all the whitespace from an std::string object, however excluding parts within speech marks and quote marks (so basically strings), eg:

Hello, World! I am a string

Would result in:

Hello,World!Iamastring

However things within speech marks/quote marks would be ignored:

"Hello, World!" I am a string

Would result in:

"Hello, World!"Iamastring

Or:

Hello,' World! I' am a string

Would be:

Hello,' World! I'amastring

Is there a simple routine to perform this to a string? It doesn't have to be the most efficient one possible, as it will only be run once or twice every time the program runs.

Aucun commentaire:

Enregistrer un commentaire