title: Extract a substring from a variable in Ansible
body: <p>I want to remove a specific substring from a variable in Ansible and store the result into another variable. Say I have something like below:</p>
  <p><code>greeting: &quot;Hello_World&quot;</code></p>
  <p>I want to remove the substring <em>&quot;_World&quot;</em> from <em>greeting</em> and store the result in another Ansible variable.</p>
  <p><strong>Example:</strong>
  <code>greet_word: &quot;Hello&quot;</code></p>
  <p>Thanks in advance!</p>