- name: Remove Quotes from Variable
hosts: localhost
gather_facts: false
vars:
original_text: "this is \"Hello'World\""
tasks:
- name: Display Original Text
debug:
var: original_text
- name: Remove Quotes and Update Variable
set_fact:
original_text: "{{ original_text | regex_replace('[\"]', '') }}"
- name: Display Updated Text
debug:
var: original_text
The task is to remove all existing single or double quotation marks in a string.
The problem is that with the current regex, only the double quotation marks in the string are deleted.
However, if I change the regex in this way regex_replace('[\'\"]', ''), I receive an error message. Therefore, my question is: What regex is correct for this task?