Using special characters in filtered strings

10 views
Skip to first unread message

Tomasz Kuchta

unread,
Nov 16, 2015, 3:08:19 PM11/16/15
to Ansible Project
Hi,

I got stuck with the following:
Imagine we have a string in stdout of a command that we would like to filter out:

Error123: some 'thing' (happened)

If we want to filter that out we would do something like

"{{ item.stderr.regex_replace('Error[0-9]+: some \\'thing\\' \\(happened\\)', '') }}"

However due to the fact that we have a colon, a single quote and brackets in our string I was unable to come up with the right escape sequence - whatever I tried, it always failed on one of these. 

What would be the right way to escape these special character when they are also used in 
the filter function like regex_replace?

Thanks!
Reply all
Reply to author
Forward
0 new messages