# lineinfile single quotes in regexp

**URL:** <https://forum.ansible.com/t/lineinfile-single-quotes-in-regexp/23030>\
**Category:** Ansible Project\
**Created:** [November 15, 2016, 3:29pm UTC](https://forum.ansible.com/t/lineinfile-single-quotes-in-regexp/23030 "2016-11-15T15:29:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alix\_Ak](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@Alix\_Ak](https://forum.ansible.com/u/Alix_Ak)\
**Post date:** [November 15, 2016, 3:29pm UTC](https://forum.ansible.com/t/lineinfile-single-quotes-in-regexp/23030/1 "2016-11-15T15:29:47Z")

</div>

hallo,

i need to uncomment this statement :

```auto
   # '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

---

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [November 15, 2016, 3:41pm UTC](https://forum.ansible.com/t/lineinfile-single-quotes-in-regexp/23030/2 "2016-11-15T15:41:24Z")

</div>

Had the same problem not long ago. Escaping here works with doubling the single quote.

---

<div class="post-metadata">

**Author:** ![Alix\_Ak](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@Alix\_Ak](https://forum.ansible.com/u/Alix_Ak)\
**Post date:** [November 15, 2016, 3:51pm UTC](https://forum.ansible.com/t/lineinfile-single-quotes-in-regexp/23030/3 "2016-11-15T15:51:59Z")

</div>

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.`
