My implementation was the first thing that popped into my head. Yours works too (although note that yours will probably reallocate memory every time it chops the end off the string, so it'll be slower). A RD parser or finite state machine would also work. My point was rather that regular expressions are a much better tool for this type of task (see the reasons given at the end of my previous comment).
Writing fewer lines of code to do the same job is usually a good idea, providing it remains understandable. Personally, I find the syntax of regular expressions pretty straightforward and a lot of languages even allow you write comments within them to make them even easier to follow.
Writing fewer lines of code to do the same job is usually a good idea, providing it remains understandable. Personally, I find the syntax of regular expressions pretty straightforward and a lot of languages even allow you write comments within them to make them even easier to follow.