Regex help: processing parameters

  • Thread starter Thread starter Julie
  • Start date Start date
J

Julie

Suppose a string of the following format:

/field=value string /field2=value string2 /field3=value string3

where

field is [a-z], [0-9], and _

value string is any alphanumeric text that doesn't include =, but may include /

What is the regex expression that will split this into field & value?

Thanks
 
I know this doesn't answer your question directly, but you may be able to use
the InstallContext.Parameters property instead of Regex to split the
parameters into name/value pairs.

using System.Configuration.Install;
using System.Collections.Specialized;

class MyClass
{
public static void Main(string[] args)
{
InstallContext context = new InstallContext(null, args);
StringDictionary parameters = context.Parameters;

string value1 = parameters["field1"];
string value2 = parameters["field2"];
string value3 = parameters["field3"];
...
}
}
 
Back
Top