lineinfile single quotes in regexp

72 views
Skip to first unread message

Dader Grund

unread,
Nov 15, 2016, 10:29:47 AM11/15/16
to Ansible Project
hallo,

i need to uncomment this statement :
   # 'Mirroring',
in gitolite.rc .

The problem is that 'Mirroring' contains quotes.
- { regexp: '^(\s*)#? *(\'Mirroring,\')',  line: "'Mirroring'," }

when i run the task containing this regexp i get  this syntax error:

The offending line appears to be:

       - { regexp: '^(\s*)#? *(\'Mirroring,\')",  line: "'Mirroring',' }
                      ^ here


Jürgen Haas

unread,
Nov 15, 2016, 10:41:25 AM11/15/16
to Ansible Project
Had the same problem not long ago. Escaping here works with doubling the single quote.
Message has been deleted

Dader Grund

unread,
Nov 15, 2016, 10:51:59 AM11/15/16
to Ansible Project
exactly! Thanks for replying :)
Inside single quotes, you can represent a single quote in your string by using two single quotes next to each other.
Reply all
Reply to author
Forward
0 new messages