Hello,
I’ve a file that may or may not be start with line filled with null-bytes (\u0000\u0000…).
I’ve written a conditional that was supposed to catch it
positions['content'] | b64decode | regex_search('^\\0+$')
But I get an error
fatal: [REDACTED]: FAILED! => {"msg": "The conditional check positions['content'] | b64decode | regex_search('^\\0+$') failed. The error was: Invalid conditional detected: source code string cannot contain null bytes\n\nThe error appears to be in '/etc/ansible/tasks/MonitorTasks.yml': line 6, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Print returned information\n ^ here\n"}
I’ve tried to replace it with \u0000
, \\u0000
, \0
but I get the same error.
I’m have to use \\S
for now, but this expression also catches many valid cases.
How do I check for a string of null bytes, terminated by \r
or \n
?
What’s the ansible syntax for regex?
UPD: Looks like regex_search('^\\\u0000+$')
doing the job, but is it the best way to do it?