Splitting On Whitespace
If you have a string with spaces and you want to split the string into a vector of strings (delimited by the spaces), then you can do something like this:
However, if you have extra spaces in your string, the output may not be quite what you want:
A quick fix might look like this:
That's nice, but it is going to fall over as soon as we run into input with tabs and new lines. Assuming we want to split on all whitespace, we should tell our regular expression to do just that:
Last updated