Ansible regex_replace and replace

Hi all,

I have two task :

  • name: “Utilisation du replace dans un fichier”
    set_fact:
    mon_fichier: “{{ lookup(‘file’, ‘/home/ansible/file.txt’) | replace(‘\n’, ’ ') }}”

and

  • name: “Utilisation du regex_replace dans un fichier”
    set_fact:
    new_file: “{{ lookup(‘file’, ‘/home/ansible/file.txt’) | regex_replace(‘mon’,‘le’) }}”

The problem is that this both tasks do the same action.
So what is a difference between the two module replace and regex_replace ?

Thanks for your help guy !! :wink:

Regards,

I am only guessing here but I would assume ‘replace’ just doesn’t use regex syntax to accomplish the same goal.