It's not clear what you want to do with the spaces. Here is an example that mixes Regex with Double.TryParse...
string[] tests = {
"3 500,00",
"500,50",
"5,55",
"3 400 500,00",
};
string pattern = @"(?<tryFloat>[\d,.]+)(\s*(?<tryFloat>[\d,.]+))*";
Thread.CurrentThread.CurrentCulture = new CultureInfo("Fr-fr", true);
foreach (string test in tests)
{
foreach (Match mx in Regex.Matches(test, pattern))
{
foreach (Capture cx in mx.Groups["tryFloat"].Captures)
{
double dbl = 0.0;
if(Double.TryParse(cx.Value,out dbl))
{
Console.WriteLine("{0} is a valid floating point number",cx.Value);
}
else
{
Console.WriteLine("{0} is NOT a valid floating point number",cx.Value);
}
}
}
}
Les Potter, Xalnix Corporation,
Yet Another C# Blog