# Extracting domain from email address

**URL:** <https://discuss.rapid7.com/t/extracting-domain-from-email-address/4887>\
**Category:** Workflows\
**Created:** [May 11, 2021, 7:36pm UTC](https://discuss.rapid7.com/t/extracting-domain-from-email-address/4887 "2021-05-11T19:36:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaron\_denton](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/a/aca169/32.png) [@aaron\_denton](https://discuss.rapid7.com/u/aaron_denton)\
**Post date:** [May 11, 2021, 7:36pm UTC](https://discuss.rapid7.com/t/extracting-domain-from-email-address/4887/1 "2021-05-11T19:36:48Z")

</div>

Trying to extract domain from an email address to use in checks with VirusTotal and ThreatCrowd.  
I’m guessing the best way is to use a pattern match in the workflow, but I’m just not quite figuring out the pattern to extract the domain and set a domain variable in the output.

---

<div class="post-metadata">

**Author:** ![aaron\_denton](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/a/aca169/32.png) [@aaron\_denton](https://discuss.rapid7.com/u/aaron_denton)\
**Post date:** [May 12, 2021, 2:04pm UTC](https://discuss.rapid7.com/t/extracting-domain-from-email-address/4887/2 "2021-05-12T14:04:15Z")

</div>

I got some help from support and figured this out.

When input is an email address, this pattern extracts the domain and outputs as domain variable.

@{{domain:/\S+.\*/}}

Also got help from this [Developing and Debugging Regex for the Pattern Match Step](https://discuss.rapid7.com/t/developing-and-debugging-regex-for-the-pattern-match-step/3636)
