<p>I'm looking for a method to assign variables with patterns in regular expressions with C++ .NET
something like </p>

<pre><code>String^ speed;
String^ size;
</code></pre>

<p>"command SPEED=[speed] SIZE=[size]"</p>

<p>Right now I'm using IndexOf() and Substring() but it is quite ugly</p>

If you put all the variables in a class, you can use reflection to iterate over its fields, getting their names and values and plugging them into a string.
Given an instance of some class named InputArgs:
```
```
foreach (FieldInfo f in typeof(InputArgs).GetFields()) {
    string = Regex.replace("\\[" + f.Name + "\\]",
        f.GetValue(InputArgs).ToString());
}
```
```