# Help me to parse a string to fields (grok)

**URL:** <https://discuss.elastic.co/t/help-me-to-parse-a-string-to-fields-grok/308903>\
**Category:** Elasticsearch\
**Created:** [July 5, 2022, 11:53am UTC](https://discuss.elastic.co/t/help-me-to-parse-a-string-to-fields-grok/308903 "2022-07-05T11:53:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kosodrom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kosodrom/32/99278_2.png) [@Kosodrom](https://discuss.elastic.co/u/Kosodrom)\
**Post date:** [July 5, 2022, 11:53am UTC](https://discuss.elastic.co/t/help-me-to-parse-a-string-to-fields-grok/308903/1 "2022-07-05T11:53:05Z")

</div>

Hi folks,

I have following key:

`key = "value1/value2/value3"`

or

`key = "value1/value2/value3/value4"`

I want to split this to following structure:

```auto
key1: value1
key2: value2
key3: value3

```

This would be easy by using a grok like

`%{WORD:key1}/%{WORD:key2}/%{GREEDYDATA:key3}` (greedydata because I want to get everything after value3 in one field).

However this works only when there is the delimiter `"/"` at the end of the string I cannot manage to make this grok work for both scenarios: When there are 3 values ore more than 3. Do you have an Idea how I can make this grok work?

---

<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:** [August 2, 2022, 11:53am UTC](https://discuss.elastic.co/t/help-me-to-parse-a-string-to-fields-grok/308903/2 "2022-08-02T11:53:58Z")

</div>

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