Ansible is built with Python, and many things in there relate to the way Python works. String replacement, however, is slightly different. Trying to run the following playbook:
---
- tasks:
- debug:
msg: "{{ string.replace('something', 'some', 'any') }}"