# Grok pattern for Names

**URL:** <https://discuss.elastic.co/t/grok-pattern-for-names/53476>\
**Category:** Logstash\
**Created:** [June 21, 2016, 9:51am UTC](https://discuss.elastic.co/t/grok-pattern-for-names/53476 "2016-06-21T09:51:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanju1323](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sanju1323](https://discuss.elastic.co/u/sanju1323)\
**Post date:** [June 21, 2016, 9:51am UTC](https://discuss.elastic.co/t/grok-pattern-for-names/53476/1 "2016-06-21T09:51:19Z")

</div>

Hi,

Can someone suggest grok pattern for the following names

```
 Mr. Rakesh Kumar Reddy
 Mr Harish Shankar
 Mr M. D. S. Reddy
 Mr. M D S Reddy
 Mr M.D.S. Reddy

```

These are the names that are present in Name field.  
Here, I want to extract the names based on space and need to remove the single letter words.  
for this I have used the grok pattern

```
(?<Courtesy>[\w\.]+) (%{NOTSPACE:FName})? (%{NOTSPACE:MName})? (%{NOTSPACE:LName})?

```

This is working fine for the names like

```
 Mr. Rakesh Kumar Reddy
 Mr Harish Shankar

```

For the above pattern I'm getting this result

```
Name : Mr. Rakesh Kumar Reddy
Courtesy : Mr
FName : Rakesh
MName : Kumar
LName : Reddy

```

But For the names like

```
Mr M. D. S. Reddy
Mr. M D S Reddy
Mr M.D.S. Reddy

```

I need the output like

```
Courtesy : Mr
FName : Reddy

```

which means all the single letter words should not be considered.  
Can anyone suggest me a grok pattern for this?

---

<div class="post-metadata">

**Author:** ![cb2015](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@cb2015](https://discuss.elastic.co/u/cb2015)\
**Post date:** [June 21, 2016, 3:34pm UTC](https://discuss.elastic.co/t/grok-pattern-for-names/53476/2 "2016-06-21T15:34:16Z")

</div>

If you make your own grok using this regex, it should work:

[\w]{2,}

I would definitely test that out a bit someplace like [regexr.com](http://regexr.com), but I believe that will match on all groups of letters that are 2 characters long, or longer.

---

<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:** [July 6, 2017, 4:51am UTC](https://discuss.elastic.co/t/grok-pattern-for-names/53476/3 "2017-07-06T04:51:26Z")

</div>


