title: match a specific word within square brackets using regex
body: <p>I have a file /home/ec2-user/hosts in which there is a group called [sample_word_test] with the square brackets and I want to add an Ip address under this group using ansible playbook. I want to match [sample_word_test] using lineinfile regex expression and add Ip address under that matching group</p>
  
  <p>Following is my playbook code</p>
  
  <pre><code>lineinfile:
      path: /home/ec2-user/hosts
      regexp: "\[.*?sample_word_test.*$\]"
      line: "{{ new_server_ip }}"
      backup: yes
  </code></pre>