The online racing simulator
Help with .NET Regular expressions...
Hey,

What I am making:
A c# dedicated host config editor

What I did and wich worked, is splitting my content on \n and just read every line and if it started with / and contained = then I read it out and print it on a form.

You could wonder, why not making a static form? Well that's easy... this method will automaticly "read" new config parameters if another one gets added...

However, to get to the point, I was trying to get rid of my noobish may of reading those configs and tried regular expressions... However it's not working right...

Since each "config" block matches this pattern:


Example:
// optional: local specified ip address
/ip=95.211.128.30

Pattern:
// *description*
/*name*=*value*

My code:

Regex test = new Regex(@"\n// (?<description>\w+)\n/(?<name>\w+)=(?<value>\w+)");
MatchCollection coll = test.Matches(content);
foreach (Match match in coll)
{
Label lbl = new Label();
lbl.Text = match.Groups["name"].Value + "<br>";
lbl.Text += match.Groups["description"].Value + "<br>";
lbl.Text += match.Groups["value"].Value + "<br>";
customConfigurator.Controls.Add(lbl);
}

Tho it doesn't seem to find anything... anyone knows what it might be?
Sorry for the spam... Found a good tool "Rad Software Regular Expressions" wich helped me solving it:

Regex test = new Regex(@"// (?<description>[^\r\n]+)\r\n/(?<disabled>[/]?)(?<name>\w+)=(?<value>[^\r\n]+)");

Did the trick

FGED GREDG RDFGDR GSFDG