# Need help with Pattern Capture Token Filter

**URL:** <https://discuss.elastic.co/t/need-help-with-pattern-capture-token-filter/301469>\
**Category:** Elasticsearch\
**Created:** [April 4, 2022, 8:17am UTC](https://discuss.elastic.co/t/need-help-with-pattern-capture-token-filter/301469 "2022-04-04T08:17:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dishant.sharma](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dishant.sharma](https://discuss.elastic.co/u/dishant.sharma)\
**Post date:** [April 4, 2022, 8:17am UTC](https://discuss.elastic.co/t/need-help-with-pattern-capture-token-filter/301469/1 "2022-04-04T08:17:11Z")

</div>

I am currently using the Pattern Capture Group Token Filter inside an Elasticsearch plugin. Currently, the plugin is working absolutely fine and is emitting the tokens also. But, the issue is that the pattern which I am using inside the Pattern Capture Group Token Filter, it is returning only the first match and not continuing the matching after it.

My Pattern Capture Token Filter definition inside the TokenFilterFactory file looks like the below one:

`PatternCaptureGroupTokenFilter(tokenStream, true, Pattern.compile("(?<![\\p{Alnum}])(\\p{Alnum}+\\p{Punct}\\p{Alnum}+)"))`

The pattern that I want to test is "(?\<![\p{Alnum}])(\p{Alnum}+\p{Punct}\p{Alnum}+)".I want to test it on the string: ":port&hid$query-input" And, I am expecting the following tokens as output. port&hid, hid$query, query-input

---

<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 2, 2022, 8:17am UTC](https://discuss.elastic.co/t/need-help-with-pattern-capture-token-filter/301469/2 "2022-05-02T08:17:57Z")

</div>

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