Ansible lineinfile not working as expected (newbie question)

I’m learning Ansible for a new project, and I’m stuck on what looks like a basic issue.
Using lineinfile with backrefs and \1 doesn’t work for me.

Simplified playbook to comment out a line starting with “This”:

You haven’t actually created a group reference. You have to wrap what you want to reference in () to create a group

So maybe something like:

regexp=‘^(This.*)’ line=‘#\1’

Aha, thank you, that worked, at least after I changed \1 to \1. Now I understand what group reference and those () I was seeing in examples mean; the \1 and \2 reference those in order.