# Problem: regex should find the end of the line - take the next new line

**URL:** <https://forum.ansible.com/t/problem-regex-should-find-the-end-of-the-line-take-the-next-new-line/28797>\
**Category:** Ansible Project\
**Created:** [October 16, 2018, 10:34am UTC](https://forum.ansible.com/t/problem-regex-should-find-the-end-of-the-line-take-the-next-new-line/28797 "2018-10-16T10:34:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shlomit\_Afgin](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@Shlomit\_Afgin](https://forum.ansible.com/u/Shlomit_Afgin)\
**Post date:** [October 16, 2018, 10:34am UTC](https://forum.ansible.com/t/problem-regex-should-find-the-end-of-the-line-take-the-next-new-line/28797/1 "2018-10-16T10:34:16Z")

</div>

Hi,  
I have

`

- name: update file1 with 0 in the end if it missing  
replace:  
backup: yes  
dest: /tmp/file1  
regexp: ‘^(start of line.\*[^0])$’  
replace: ‘\1 0’

`

This add 0 to lines that start with “start of line”.

It’s run okay if there are no empty lines between.  
If there is empty line under the match line it add the 0 to the empty line.  
For example, the 2 lines:

`  
start of line fjhdsjkfhdsk

`

will be:

`start of line fjhdsjkfhdsk 0`

instead of:

`  
start of line fjhdsjkfhdsk 0

`

I tried to add the (?\<!0) the look behind - but don’t work at all.  
How can I make it catch the first new line?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 16, 2018, 3:14pm UTC](https://forum.ansible.com/t/problem-regex-should-find-the-end-of-the-line-take-the-next-new-line/28797/2 "2018-10-16T15:14:00Z")

</div>

It's in the documentation of the module under regexp.
