# GROK Pattern syntax error, working in GROK debugger but not pipeline

**URL:** <https://discuss.elastic.co/t/grok-pattern-syntax-error-working-in-grok-debugger-but-not-pipeline/334707>\
**Category:** Elasticsearch\
**Tags:** ingest-pipeline\
**Created:** [May 30, 2023, 5:46pm UTC](https://discuss.elastic.co/t/grok-pattern-syntax-error-working-in-grok-debugger-but-not-pipeline/334707 "2023-05-30T17:46:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhoward](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@mhoward](https://discuss.elastic.co/u/mhoward)\
**Post date:** [May 30, 2023, 5:46pm UTC](https://discuss.elastic.co/t/grok-pattern-syntax-error-working-in-grok-debugger-but-not-pipeline/334707/1 "2023-05-30T17:46:35Z")

</div>

Hey all. I'm trying to create a GROK pattern on a longer text message to break it into several fields. The error I'm having is when I try to make a field of a specific set of numbers from a larger set of numbers.

For simplicity's sake, here's an example:

Say I have "123456789". I want to return a value of "12345".

```auto
(?<CardNumber>.d{5})

```

The above works in Grok debugger.

However, when I try to add it as a Grok processor I get an "Invalid JSON string".

 ![pattern1](https://us1.discourse-cdn.com/elastic/original/3X/7/3/736d4035c699b699b9b9e1d26043939b97c7320b.png)

I'm new to using Grok patterns and haven't been able to track down the specific syntax error I'm making and why there would be a difference in Grok debugger and using it in a pipeline

---

<div class="post-metadata">

**Author:** ![mhoward](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@mhoward](https://discuss.elastic.co/u/mhoward)\
**Post date:** [May 30, 2023, 7:51pm UTC](https://discuss.elastic.co/t/grok-pattern-syntax-error-working-in-grok-debugger-but-not-pipeline/334707/2 "2023-05-30T19:51:20Z")

</div>

I figured out my own problem! Here's the correct syntax works:

```auto
(?<CardNumber>[0-9]{5})

```

Just created a pipeline with this and it returned the first 5 numbers as I wanted above. Hope this helps someone out someday.

---

<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:** [June 27, 2023, 7:51pm UTC](https://discuss.elastic.co/t/grok-pattern-syntax-error-working-in-grok-debugger-but-not-pipeline/334707/3 "2023-06-27T19:51:35Z")

</div>

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