# Grok pattern for capturing string with CR in the middle

**URL:** <https://discuss.elastic.co/t/grok-pattern-for-capturing-string-with-cr-in-the-middle/178391>\
**Category:** Logstash\
**Created:** [April 25, 2019, 8:08am UTC](https://discuss.elastic.co/t/grok-pattern-for-capturing-string-with-cr-in-the-middle/178391 "2019-04-25T08:08:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![royboy](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@royboy](https://discuss.elastic.co/u/royboy)\
**Post date:** [April 25, 2019, 8:08am UTC](https://discuss.elastic.co/t/grok-pattern-for-capturing-string-with-cr-in-the-middle/178391/1 "2019-04-25T08:08:06Z")

</div>

Hi All  
new here and in general to Logs in general  
i have encountered problem to generate a Grok (for an extractor) pattern so it will capture string cut in the middle (sometimes) by a CR and continues, i want to capture it all to one variable (not containing the CR and spaces if exists)  
the string is  
2019-04-14 15:15:26 0x2b92f0e00700[A  
WS\_OSCAR\_INFO]:Taking preemptive lock on ''.bla bla bla'  
i want to capture the AWS\_OSCAR\_INFO as a parameter loglevel  
searched a lot , and tried myself but couldnot solve it  
the max is that i got parameter containg A WS\_OSCAR\_INFO , but i want it without the space  
thanks for the helpers...

---

<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:** [April 25, 2019, 1:56pm UTC](https://discuss.elastic.co/t/grok-pattern-for-capturing-string-with-cr-in-the-middle/178391/2 "2019-04-25T13:56:53Z")

</div>

Try

```
    grok { match => { "message" => "\[%{DATA:foo}\]" } }
    mutate { gsub => ["foo", "\s*", ""] }
```

---

<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 23, 2019, 1:57pm UTC](https://discuss.elastic.co/t/grok-pattern-for-capturing-string-with-cr-in-the-middle/178391/3 "2019-05-23T13:57:01Z")

</div>

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