Avoid decimal.TryParse to recognize "1.1.1" or "1,1,1" as decimal
<p>I have a problem in string recognition: I'm trying to recognize a number only in correct format, but don't find how.</p>

<p>I'm writing a culture invariant way so I need to recognize "," and "." as decimal and thousand separator and vice-versa.</p>

<p>All these are correct format for me:</p>

<pre><code>12,1
12.1
1.000,12
1,000.12
</code></pre>

<p>but things like these are wrong</p>

<pre><code>1.2.3
1,2,3
</code></pre>

<p>I tried:</p>

<pre><code>NumberStyles style;
decimal n;  
object valore;                                  
style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowThousands;

Console.WriteLine(decimal.TryParse(valore.ToString(), style , CultureInfo.InvariantCulture, out n));
</code></pre>

<p><a href="https://dotnetfiddle.net/BrO7L1" rel="nofollow">this is the fiddle to test it</a></p>

<p>But "1,1,1" is read as valid number while "1.1.1" is not.</p>

<p>If I use my specific culture ("it-IT"), "1,1,1" is recognized and "1.1.1" is not.</p>

<p>How can I discard all not valid strings?</p>