# Parse content type

**URL:** <https://discuss.elastic.co/t/parse-content-type/168690>\
**Category:** Logstash\
**Created:** [February 16, 2019, 2:34pm UTC](https://discuss.elastic.co/t/parse-content-type/168690 "2019-02-16T14:34:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Babak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babak/32/44723_2.png) [@Babak](https://discuss.elastic.co/u/Babak)\
**Post date:** [February 16, 2019, 2:34pm UTC](https://discuss.elastic.co/t/parse-content-type/168690/1 "2019-02-16T14:34:25Z")

</div>

I'm parsing a log message with arbitrary fields. In my message we have field within two quotations in these two formats

```auto
"text/html"
"text/html; charset=UTF-8"

```

I can handle each one separately.  
For first one I use `"%{WORD:type}/%{DATA:subtype}"` and for the second one I use `"%{WORD:type}/%{DATA:subtype}; charset=%{DATA:encoding}"` but how can I use grok to handle both type simultaneously?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 16, 2019, 2:59pm UTC](https://discuss.elastic.co/t/parse-content-type/168690/2 "2019-02-16T14:59:43Z")

</div>

You could use

```
"%{WORD:type}/%{WORD:subtype}(; charset=%{GREEDYDATA:encoding})?"
```

---

<div class="post-metadata">

**Author:** ![Babak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babak/32/44723_2.png) [@Babak](https://discuss.elastic.co/u/Babak)\
**Post date:** [February 17, 2019, 7:33am UTC](https://discuss.elastic.co/t/parse-content-type/168690/3 "2019-02-17T07:33:28Z")

</div>

Tnx.

---

<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 17, 2019, 7:33am UTC](https://discuss.elastic.co/t/parse-content-type/168690/4 "2019-03-17T07:33:43Z")

</div>

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