Hello @Nicholas Piazza ,
I understand what you want want to achieve.
Using the string.split() is perhaps not the best solution...
Have you already checked out RegEx? There you can get an array of groups of characters...
I found this possible solution:
[^\s"']+|"([^"]*)"|'([^']*)'
It turns your example in four groups:
Yes, there is a learning curve with RegEx but it's worth it!
The tester I used, even generated this code:
using System;
using System.Text.RegularExpressions;public class Example
{
public static void Main()
{
string pattern = @"[^\s""']+|""([^""])""|'([^'])'";
string input = @"firstarg second-arg third:arg ""fourth arg""";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Regards,
Sander