# How to get first match regex grok

**URL:** https://discuss.elastic.co/t/how-to-get-first-match-regex-grok/222339
**Category:** Logstash
**Created:** [March 5, 2020, 4:27pm UTC](https://discuss.elastic.co/t/how-to-get-first-match-regex-grok/222339 "2020-03-05T16:27:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nino](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nino](https://discuss.elastic.co/u/nino)
#### Post date: [March 5, 2020, 4:27pm UTC](https://discuss.elastic.co/t/how-to-get-first-match-regex-grok/222339/1 "2020-03-05T16:27:48Z")

</div>

Dear all,

I want to retrieve only "14" from this message

`3/03/0 EE 14 GFR 20 AAA XXXXX 50 3365.00`

this is my grok code

```
grok{
 match => {
        field1 => [
          "(?<number_extract>\d{0}\s\d{1,3}\s{1})"       
        ]         
      }
}

```

I would like to match just "14" first match

Best regards

---

<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: [April 2, 2020, 4:27pm UTC](https://discuss.elastic.co/t/how-to-get-first-match-regex-grok/222339/2 "2020-04-02T16:27:52Z")

</div>

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