# Grok Pattern that captures lines\\events that starts with a specific text

**URL:** <https://discuss.elastic.co/t/grok-pattern-that-captures-lines-events-that-starts-with-a-specific-text/41138>\
**Category:** Logstash\
**Created:** [February 7, 2016, 1:08pm UTC](https://discuss.elastic.co/t/grok-pattern-that-captures-lines-events-that-starts-with-a-specific-text/41138 "2016-02-07T13:08:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![techrawther](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@techrawther](https://discuss.elastic.co/u/techrawther)\
**Post date:** [February 7, 2016, 1:08pm UTC](https://discuss.elastic.co/t/grok-pattern-that-captures-lines-events-that-starts-with-a-specific-text/41138/1 "2016-02-07T13:08:51Z")

</div>

I have a pattern word that appears multiple times in my logs. I want to set a tag for those lines which starts with a nonspace + the pattern text + Any data.

Following is a snippet from my log

```
Changeset: http://hg.frairy.sams.net/jdk/hs-comp/rev/94f9
Changeset: http://hg.frairy.sams.net/jdk/hs-comp/rev/f3827
Word :
Failures:
   This is Changeset: xyz

```

I tried following grok but is not working as I expected

```
 %{NOTSPACE}Changeset:%{SPACE}%{URI}
 Changeset:%{SPACE}%{GREEDYDATA}

```

I cannot use the second one as it may match other lines that has "Changeset: " text.

Need help with a grok that a line start with no space + Changeset: + Any data after that

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 7, 2016, 2:21pm UTC](https://discuss.elastic.co/t/grok-pattern-that-captures-lines-events-that-starts-with-a-specific-text/41138/2 "2016-02-07T14:21:38Z")

</div>

This should work:

```
^Changeset:%{SPACE}%{URI}

```

Your first attempt doesn't work because `NOTSPACE` is defined as `\S+`, and the line you want to match doesn't contain at least one non-space character before "Changeset:".

---

<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:** [July 6, 2017, 5:12am UTC](https://discuss.elastic.co/t/grok-pattern-that-captures-lines-events-that-starts-with-a-specific-text/41138/3 "2017-07-06T05:12:48Z")

</div>


