# Multiple matches with a single regex

**URL:** <https://discuss.elastic.co/t/multiple-matches-with-a-single-regex/69811>\
**Category:** Logstash\
**Created:** [December 22, 2016, 3:00pm UTC](https://discuss.elastic.co/t/multiple-matches-with-a-single-regex/69811 "2016-12-22T15:00:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jetnet](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@jetnet](https://discuss.elastic.co/u/jetnet)\
**Post date:** [December 22, 2016, 3:00pm UTC](https://discuss.elastic.co/t/multiple-matches-with-a-single-regex/69811/1 "2016-12-22T15:00:49Z")

</div>

Hi logstash users!

is it possible to catch all matches (global match) with a single regex?  
E.g. given the following text, which gets processed by `multiline` plugin first:

```auto
Caused by: a.b.c.Exception1: text1
Caused by: a.b.c.Exception2: text2

```

and the corresponding `grok` match:

```auto
grok {
	match => {
		"message" => "(?m)Caused by: (?<exception>[\w\.\$]+):\s+?(?<reason>[^\n]+)"
	}
}

```

Unfortunately it captures just the first match:

```auto
{
  "exception": [
    "a.b.c.Exception1"
  ],
  "reason": [
    "text1"
  ]
}

```

I'd like to have an array with both exceptions and text.

Is it possible at all?  
Thank you!

---

<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:** [January 19, 2017, 3:00pm UTC](https://discuss.elastic.co/t/multiple-matches-with-a-single-regex/69811/2 "2017-01-19T15:00:56Z")

</div>

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