# Need help manipulating shell stdout data

**URL:** <https://forum.ansible.com/t/need-help-manipulating-shell-stdout-data/18225>\
**Category:** Ansible Project\
**Created:** [May 13, 2015, 8:44pm UTC](https://forum.ansible.com/t/need-help-manipulating-shell-stdout-data/18225 "2015-05-13T20:44:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [May 13, 2015, 8:44pm UTC](https://forum.ansible.com/t/need-help-manipulating-shell-stdout-data/18225/1 "2015-05-13T20:44:29Z")

</div>

I have a shell task that registers data that looks similar to:

“stdout\_lines”: [  
“username\tuseremail@domain.tld”,  
“username\tuseremail@domain.tld”,  
“username\tuseremail@domain.tld”,  
“username\tuseremail@domain.tld”,  
…,  
]

What I’d really like to end up with is a variable that contains a list/has similar to { username: “username”, emailprefix: “useremail”, emaildomain: “domain.tld” }, { username: “username”, emailprefix: “useremail”, emaildomain: “domain.tld” }, … { username: “username”, emailprefix: “useremail”, emaildomain: “domain.tld” }

Currently I’ve been trying to get the “useremail” part of each of those lines out so I can do something with it.

So far I’ve tried using this regex “\t[a-zA-Z-]+@” and the regex\_replace and match jinja filters.

match returns true or false as far as I can tell.

regex\_replace lets me easily replace “useremail” with something, but not actually get “useremail” out of it.

For example, I can replace “useremail” with a space like this:

- debug: msg=“{{ item|regex\_replace(‘\t[a-zA-Z-]+@’,’ ') }}”  
with\_items: userinfo.stdout\_lines

But that’s not very helpful…

Any suggestions on how I can get what I want?

Note that the regex above also matches the \t and @ characters when tested on [regexpal.com](http://regexpal.com).
