On 22.03.2019 19:49, John Harmon wrote:
> 
> 
> On Friday, March 22, 2019 at 11:23:15 AM UTC-6, John Harmon wrote:
>>
>> You are right.... I switched to lineinfile sometime between yesterday and
>> today.  I switched back to replace due to your success (and I prefer to use
>> it as I believe it will replace all found instances).
>>
>> Seems to be working now, however, one follow-up question regarding
>> backrefs.  I thought \1 replaced the content of group1?  Is that
>> incorrect?  The content that was replaced doesn't  fall in a group (sorry,
>> I lack experience with backrefs).
>> Here is my regex tester.  You can see the "full match" is replaced, and
>> not the "Group 1": https://regex101.com/r/jfGg83/4
>>
> 
> Oh, I think I misunderstood (as I suspected) how backrefs work with
> substitution.  I thought what was referenced was being replaced, when in
> reality it seems to just be putting back what we want to keep and just
> replacing the rest.


Yes, all the things matching the regexp: line will be replaced with the content 
of the replace: line.
Since nameservers: and address: shouldn't be discard/replace, the parenthesis 
around them make it so that we can reference them as \1 in the replace: line.


-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e005b3b2-6d02-2a81-9330-e97b3c382e89%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to