Help need - Trimming unnecessary characters from the output

I’m new to the Ansible world. I’m trying to create a playbook that gets the MD5 value from the Cisco IOS. The IOS verification run on Cisco with bunch of dots and give the MD5 at the end (below)

…Done! verify /md5 (flash:cat3k_caa-universalk9.16.12.04.SPA.bin) = 4bb3ad09220d0d38131662296568c717

I’m trying to get just the MD5 value after the equal sign and write it to file. I tried the below but no luck.

  • name:checking the md5 ios_command: commands: - “verify /md5 flash:{{ios_file_name}} {{md5_value}}”
    msg: {{md5_result.stdout | regex.replace(‘.’ , ‘’)}}
    register: removed

However the output of the remove variable still has all the dots. Could someone please assist me, I’m pretty sure the regex I use is not correct either. Thank you very much in advance.

I'm new to the Ansible world. I'm trying to create a playbook that gets the MD5 value from the Cisco IOS. The IOS
verification run on Cisco with bunch of dots and give the MD5 at the end (below)

*.........................................................................................................................................................Done!
verify /md5 (flash:cat3k_caa-universalk9.16.12.04.SPA.bin) = 4bb3ad09220d0d38131662296568c717 *

I'm trying to get just the MD5 value after the equal sign and write it to file. I tried the below but no luck.

- name:
checking the md5 ios_command: commands: - "verify /md5 flash:{{ios_file_name}} {{md5_value}}"
msg: {{md5_result.stdout | regex.replace('.' , '')}}
register: removed

However the output of the remove variable still has all the dots. Could someone please assist me, I'm pretty sure the
regex I use is not correct either. Thank you very much in advance.

"." is a special character in a regular expression, so you have to escape it as '\.'.
To catch multiple occurrences in a row add a plus sign '\.+'.

Regards
         Racke