Regex for decimal number with optional decimal point
<p>My requirement is to test the pasted data and if it fails then don't paste.</p>

<pre><code>Regex: /\d{0,4}([\.|\,]\d{0,2})?/
</code></pre>

<p>Data used: </p>

<pre><code>1.2 tests true
1.2.3 test true as well
</code></pre>

<p>Requirement is </p>

<p>min 0 max 4 digits before decimal point<br>
decimal point can be either dot or comma<br>
min 1 max 3 digits after decimal point if there exists a decimal point.</p>

<p>I have tried following but does not work.<br>
Any help will be appreciated.</p>

<p><a href="https://jsfiddle.net/ue8gj52t/200/" rel="nofollow">fiddle</a></p>