Parsing arguments foo:bar foo:bar foo:bar

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
 
P

Pavel Minaev

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top