Regex - Capturing group to return null for a non matching string
<p>I am learning regex now. My requirement is simple. This is my regex.</p>

<pre><code>([0-9]*)(\.)([0-9]*)
</code></pre>

<p>and my input is like this.</p>

<pre><code>1.9
2.8
4.76
3
7.8
</code></pre>

<p>I just want to return only decimal portion. I am currently printing 3rd capturing group $3. Output is like this.</p>

<pre><code>9
8
76
3
8
</code></pre>

<p>But my expected output is this.</p>

<pre><code>9
8
76

8
</code></pre>

<p>Please tell me how to achieve this. Whenever the string is not matching my $3 returns entire string. I want it to return null or any other default value(like '0'). Is it possible to achieve this using lookarounds? If so, how?</p>