Parsing arguments foo:bar foo:bar foo:bar

  • Thread starter Thread starter puzzlecracker
  • Start date Start date
P

puzzlecracker

array args of string internally looks like this, free spacing is
assumed: foo:bar foo1:bar foo2:bar2 ...etc. I need to quickly parse
the array into two strings each contaning foo and bar,

void Parse(string [] args )
{

// please no 3.5 features... regular expressions are welcome

}

Thanks
 
array args of string internally looks like this, free spacing is
assumed:  foo:bar foo1:bar foo2:bar2 ...etc.  I need to quickly parse
the array  into  two strings each contaning foo and bar,

Do you perhaps mean "parse the array into two arrays of strings, one
for all 'foo', another for all 'bar'"? Otherwise it doesn't make much
sense to me, unless you want to ignore everything after "foo:bar" in
the input string.

Otherwise, what exactly is the problem? Use String.Split to split into
name-value pairs, then Split on each in turn to separate names and
values; add both to the corresponding List<string> instances, and
that's it.
 
Back
Top