# Logstash - Grok - Parse Digit

**URL:** <https://discuss.elastic.co/t/logstash-grok-parse-digit/229596>\
**Category:** Logstash\
**Created:** [April 24, 2020, 8:14am UTC](https://discuss.elastic.co/t/logstash-grok-parse-digit/229596 "2020-04-24T08:14:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjo](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@pjo](https://discuss.elastic.co/u/pjo)\
**Post date:** [April 24, 2020, 8:14am UTC](https://discuss.elastic.co/t/logstash-grok-parse-digit/229596/1 "2020-04-24T08:14:35Z")

</div>

Hello,

I have this simple chain that represent a date (with 2digit year format)

200424

I'm looking for a way to parse it to obtain this output :

year : 20  
month : 04  
montday : 24

Is it possible with grok to extract part of a string / digit based on start/end position (like php function substr) ?

Thanks

---

<div class="post-metadata">

**Author:** ![pjo](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@pjo](https://discuss.elastic.co/u/pjo)\
**Post date:** [April 24, 2020, 8:42am UTC](https://discuss.elastic.co/t/logstash-grok-parse-digit/229596/2 "2020-04-24T08:42:38Z")

</div>

it look this do the job with regexp rather than grok pattern

`(?<year>([12]\d{1}))(?<month>(0[1-9]|1[0-2]))(?<monthday>(0[1-9]|[12]\d|3[01]))`

---

<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:** [May 22, 2020, 8:42am UTC](https://discuss.elastic.co/t/logstash-grok-parse-digit/229596/3 "2020-05-22T08:42:38Z")

</div>

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