I want to print only the strings between the commas and semicolons, for example in str = "word1,word2;word3;"
I thought using a regex of multiple delimiters "[,;]"
But the following code does not separate word2 and word3. It treats them as one word:
word2;word3;
No, the same string can also be: str = "word1,word2;word1,"
So the delimiter has to be either ',' or ';'
In my program, once a delimiter is chosen, it stays the same in each iteration of the while loop. But I want it to check whether the other delimiter occurs in the updated string after erase.
Please adhere to my code and tell me what the problem is.
Code is still not complete. It should:
a) compile
b) actually show an error: say, output separated strings to show that some of them are not separated properly
c) Should not have any code which is not related to the problem.
This is what minimal code illustrating problem is.