Not CSV
Sandboxed Enviroment.
I am trying to extract a few "values" from a string. The string will more or less be consistent. I have come to conclusion I will need to rely on regex for this. I can't quite figure out the regex piece.
string str1 = "test \"test1\" \"35\" TestWord Test";
string str2 = "test \"test2\" \"this is a Test\" TestWord2 Test2";
I want my result for each string to basically "split" at each space unless it is in quotes. I know this is not regex, but it is an example of what I want to accomplish.
string[] split = str1.split(' ');
This works fine, for there are no spaces in between the quotes
string[] split = str2.split(' ');
This won't work because there are spaces in between the second quoted portion.
This is why I think regex is the best bet, aside from parsing, the old fashioned way as it were.
I want every piece of extracted data from the string stored into an array.
So for the first example
string[] split = str1.split(' ');
my result should be
split[0] = test
split[1] = test1
split[2] = 35
split[3] = TestWord
split[4] = Test
and yes I would like to omit any quotes in the results.
Any ideas?
Thank you