title: Ansible modify a part of line
body: <p>I have a file called <strong><em>myfile.php</em></strong> in which I have a line : </p>
  
  <pre><code>$host:"" //this is where Ansible will add host IP address
  </code></pre>
  
  <p>I want this line to looks like :</p>
  
  <pre><code>$host:"192.168.0.12"
  </code></pre>
  
  <p>So I have two questions here: </p>
  
  <ol>
  <li>How to do so with Ansible playbook, like how to define a regular expression that says grep the line which starts with <code>$host</code> and ends with <code>//this is where Ansible will add host IP address</code> then put between <code>""</code> this IP address <code>162.168.168.0.12</code>. I want to <strong>modify</strong> this line and not to replace it although I know it will lead the same result.</li>
  <li>how to make Ansible grep this IP address automatically from the host and avoid typing it manually in the playbook.</li>
  </ol>
  
  <p>Your answers will be very helpful, Thank you.</p>