HI i am new to jinja2 and trying to use regular expression as shown below
{% if ansible_hostname == \'uat\' %}
{% set server = \'thinkingmonster.com\' %}
There is a "regex_replace" filter available in Ansible>1.6
Other Useful Filters Scroll down and you'll see this:
New in version 1.6.
To replace text in a string with regex, use the “regex_replace” filter:
# convert "ansible" to "able"
{{ 'ansible' | regex_replace('^a.*i(.*)$', 'a\\1') }}
# convert "foobar" to "bar"
{{ 'foobar' | regex_replace('^f.*o(.*)$', '\\1') }}
# convert "localhost:80" to "localhost, 80" using named groups
{{ 'localhost:80' | regex_replace('^(?P.+):(?P\\d+)$', '\\g, \\g') }}
That being said, regex is overkill for finding a solution to this particular problem.