title: Ansible regex_replace
body: <p>I'm trying to capture the main version number of a variable, and to do this I'm trying to remove the numbers after the main version number:</p>
  
  <p>In <code>variable.yml</code>:</p>
  
  <pre><code>version: 3.9.5
  main_version: "{{ version | regex_replace('^.*(..)$', '')}}"
  </code></pre>
  
  <p>This should give me <code>3.9</code>, however debug gives me nothing.</p>
  
  <p>What's the correct way of doing this? </p>
  
  <p>(And making sure that it would still be able to handle things such as <code>3.10.1</code>, so that would return a <code>main_version</code> of <code>3.10</code>, and also things such as <code>3.10.1-rcblah</code>, and that would return a <code>main_version</code> of <code>3.10</code>)</p>