title: Ansible 2.4 check for match "word" in output
body: <p>I would like to use <code>ansible</code> to check if a package name exist in an output of a command. if not exist do something.</p>
  
  <p>for example :
  I'm looking for the package "zip" but the problem is that it return "gzip" "zip" "unzip" and I'm looking to find only "zip" ,how to do it in a when condition</p>
  
  <p>How can I use regex to match the <code>{{ item.name }}</code> exactly and not words that contains part of <code>{{ item.name }}</code></p>
  
  <pre><code> - name: Check if Package is installed
        shell: dpkg-query -f '${binary:Package}\n' -W
        register: is_installed
  
      - name: Install apt dependencies
        apt:
          name: "{{item.name}}{{item.version}}"
          state: present
          allow_unauthenticated: yes
          force: yes
        with_items:
          - { name: 'python2.7', version: '' }
          - { name: 'ruby', version: '' }
          - { name: 'postgresql-9.5', version: '' }
          - { name: 'postgresql-contrib-9.5', version: '' }
          - { name: 'libpq-dev', version: '' }
          - { name: 'nodejs', version: '=9.*' }
          - { name: 'python-setuptools', version: '' }
          - { name: 'python-pip', version: '' }
          - { name: 'python-pkg-resources', version: '' }
          - { name: 'sshpass', version: '' }
          - { name: 'zip', version: '' }
          - { name: 'mongodb-org', version: '=4.0.0' }
          - { name: 'libfontconfig', version: '' }
          - { name: 'ntp', version: '' }
          - { name: 'fio', version: '' }
        when: not "{{item.name}}" in is_installed.stdout
  </code></pre>