# Help need - Trimming unnecessary characters from the output

**URL:** <https://forum.ansible.com/t/help-need-trimming-unnecessary-characters-from-the-output/34757>\
**Category:** Ansible Project\
**Created:** [March 10, 2021, 7:12am UTC](https://forum.ansible.com/t/help-need-trimming-unnecessary-characters-from-the-output/34757 "2021-03-10T07:12:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malith\_Perera](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Malith\_Perera](https://forum.ansible.com/u/Malith_Perera)\
**Post date:** [March 10, 2021, 7:12am UTC](https://forum.ansible.com/t/help-need-trimming-unnecessary-characters-from-the-output/34757/1 "2021-03-10T07:12:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [March 10, 2021, 7:32am UTC](https://forum.ansible.com/t/help-need-trimming-unnecessary-characters-from-the-output/34757/2 "2021-03-10T07:32:26Z")

</div>

> 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  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke
