Regex Group Optional
<p>I have the following regular expression that isn't working the way I thought it would.</p>

<pre><code>("^\\d{2}(?:\\d{2})?\\.\\d{2}(\\.\\d{2-4})?$");
</code></pre>

<p>I am trying to match a string that starts with either 2 or 4 digits, followed by a period, followed by 2 digits and then optionally another period and either 2 or 4 digits.</p>

<p>I would expect 33.44.4444 to work, as would 33.33 but anytime I have a string that has a 2nd period, my expression fails.</p>

<p>What am I doing wrong ?</p>