title: Ansible: What is the correct syntax for a variable within a findall regex
body: <p>I am using Ansible version 2.9.  I want to do a GET, which returns a block of info, regex an ID from that info that corresponds to whatever host I am iterating through at the moment, and then later do things with that ID.</p>
  <p>I have the regex working ( <a href="https://regex101.com/r/UL7V6r/2" rel="nofollow noreferrer">https://regex101.com/r/UL7V6r/2</a> ).  And I confirmed this regex <em>does</em> work in the playbook when I input it exactly like in the sample.  But, I need the host name at the end of that regex to be a <strong>variable</strong> matching the host I am iterating through, not a static host name.  Here is the playbook, focused on just getting the regex to work:</p>
  <pre><code>  gather_facts: no
    vars:
      the_name: &quot;{{ inventory_hostname_short }}&quot;
  
    tasks:
  
      - uri:
                    url: http://controller-sample-a1p.someplace.com/restapi/nodes
                    method: GET
                    return_content: yes
        register: nodeId
        delegate_to: 127.0.0.1
  
      - debug: msg=&quot;{{ nodeId.content | regex_findall(&quot;(\w+-\w+-\w+-\w+-\w+)..&lt;address&gt;\d+\.\d+\.\d+\.\d+:?\d+?&lt;\/address&gt;&lt;name&gt;{{ the_name }}&quot;) }}&quot;
        delegate_to: 127.0.0.1
  
     - debug:
             var: the_name
  </code></pre>
  <p>The focus is on the end of that regex, with the variable of &quot;the_name&quot;.  As you can see I am trying curly brackets here.  I've tried lots of variations insulting no brackets, single quotes, double quotes, etc.</p>
  <p>The results of this play is:</p>
  <pre><code>ok: [sampleFQDN2.place.com -&gt; 127.0.0.1] =&gt; {
      &quot;msg&quot;: []
  }
  
  TASK [debug] *************************************************************************************************************************
  ok: [sampleFQDN2.place.com] =&gt; {
      &quot;the_name&quot;: &quot;sampleFQDN2&quot;
  }
  </code></pre>
  <p>Expected result would be for debug msg one to show &quot;FJLEEJ24-3190-49F1-965D-823F63904136&quot; (per the link).</p>
  <p>So this suggests to me that the variable is correct (second debug).  And the regex is correct because if I take the variable output of &quot;sampleFQDN2&quot; and plug it in directly, that first debug spits out the right response.  Which leads me to believe I just have not found the right syntax to stick a variable in a regex_findall.</p>
  <p>Does anyone know the syntax for this?  Or even if it is possible?</p>