# Help - transform .keys() output with regex\_replace

**URL:** <https://forum.ansible.com/t/help-transform-keys-output-with-regex-replace/21977>\
**Category:** Ansible Project\
**Created:** [July 10, 2016, 11:12am UTC](https://forum.ansible.com/t/help-transform-keys-output-with-regex-replace/21977 "2016-07-10T11:12:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nico](https://avatars.discourse-cdn.com/v4/letter/n/b5a626/32.png) [@Nico](https://forum.ansible.com/u/Nico)\
**Post date:** [July 10, 2016, 11:12am UTC](https://forum.ansible.com/t/help-transform-keys-output-with-regex-replace/21977/1 "2016-07-10T11:12:25Z")

</div>

Hello

I’am using the .keys function to get the key name out of a dict.

`{{ item.keys() }}`  
which output:

`["MyKeysName"]`

Now, I’am trying to remove the _["_ and _"]_ so that only _MyKeysName_ is left.  
I have been looking at the regex\_replace filter but not being an expert at regex I’am having trouble getting it to work.  
Is regex\_replace filter the best option here or is there another recommended way?  
Any tips on what the regex should look like?

[a-zA-Z]+ should allow me to extract only the characters leaving the and " out correct?

`{{ item.keys()|regex_replace('^[a-zA-Z]+$','\\1') }}`

Running Ansible 2.2.0  
Any help or guidance is appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![Nico](https://avatars.discourse-cdn.com/v4/letter/n/b5a626/32.png) [@Nico](https://forum.ansible.com/u/Nico)\
**Post date:** [July 11, 2016, 12:47am UTC](https://forum.ansible.com/t/help-transform-keys-output-with-regex-replace/21977/2 "2016-07-11T00:47:09Z")

</div>

Just realized my mistake…  
This is a list so a simple |join(’ ') did the trick…

`  
{{ item.keys()|join(’ ') }}

`

-Nico
