# Ansible help regex

**URL:** <https://forum.ansible.com/t/ansible-help-regex/27182>\
**Category:** Ansible Project\
**Created:** [April 4, 2018, 12:00am UTC](https://forum.ansible.com/t/ansible-help-regex/27182 "2018-04-04T00:00:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Numi](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@Numi](https://forum.ansible.com/u/Numi)\
**Post date:** [April 4, 2018, 12:00am UTC](https://forum.ansible.com/t/ansible-help-regex/27182/1 "2018-04-04T00:00:05Z")

</div>

Hello, I was wondering if someone can possible help me with my Ansible playbook. I have a file called myfile.yml with a line that contains an image. Example line:

`service: blahblah image: myoldimagename blahblah`

I want to change everything after the word "image: " with a configuration line, however I’m having trouble. For example, I want to replace “myoldimagename” with “mynewline”. I don’e want to match “myoldimagename” explicitly because that may be different.

`

- name: Configure myfile.yml  
replace:  
path: /data/config/myfile.yml  
regexp: “(?\<=image: ).\*”  
replace: \1mynewline  
backup: yes  
`

---

<div class="post-metadata">

**Author:** ![PhilEv](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@PhilEv](https://forum.ansible.com/u/PhilEv)\
**Post date:** [April 4, 2018, 5:51pm UTC](https://forum.ansible.com/t/ansible-help-regex/27182/2 "2018-04-04T17:51:42Z")

</div>

see [https://www.regular-expressions.info/lookaround.html](https://www.regular-expressions.info/lookaround.html) for explanations.  
lookaround is not consuming any characters.

try on [https://regex101.com/](https://regex101.com/) to make it concrete about what is matched or not

HTH  
Phil
