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

11 views
Skip to first unread message

Shlomit Afgin

unread,
Oct 16, 2018, 6:34:17 AM10/16/18
to Ansible Project

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?

Kai Stian Olstad

unread,
Oct 16, 2018, 11:14:16 AM10/16/18
to ansible...@googlegroups.com
It's in the documentation of the module under regexp.


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages