# Email and SSN regex patterns for elastic search

**URL:** <https://discuss.elastic.co/t/email-and-ssn-regex-patterns-for-elastic-search/217869>\
**Category:** Elasticsearch\
**Created:** [February 4, 2020, 7:46pm UTC](https://discuss.elastic.co/t/email-and-ssn-regex-patterns-for-elastic-search/217869 "2020-02-04T19:46:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lisahtwy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lisahtwy/32/53910_2.png) [@Lisahtwy](https://discuss.elastic.co/u/Lisahtwy)\
**Post date:** [February 4, 2020, 7:46pm UTC](https://discuss.elastic.co/t/email-and-ssn-regex-patterns-for-elastic-search/217869/1 "2020-02-04T19:46:25Z")

</div>

Hi,

I am trying to recognize Email ids and SSNs in files using elastic search.  
Could somebody tell me the correct regexp patterns to recognize SSN and Email ids.  
I am using these below patterns:  
Email: "[a-zA-Z0-9]+@[a-zA-Z]+.[a-zA-Z]+"  
SSN: "[0-9]{3}-?[0-9]{2}-?[0-9]{4}"

Please correct me if I am wrong!!

Thanks,  
Lisa.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 5, 2020, 9:39am UTC](https://discuss.elastic.co/t/email-and-ssn-regex-patterns-for-elastic-search/217869/2 "2020-02-05T09:39:56Z")

</div>

Hey,

you could try using a grok processor and use the `EMAILADDRESS` pattern, so you don't need to write the regex yourself. Not too sure about the SSN though, if there is a predefined regex.

--Alex

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 4, 2020, 9:40am UTC](https://discuss.elastic.co/t/email-and-ssn-regex-patterns-for-elastic-search/217869/3 "2020-03-04T09:40:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
