# Regexp query and analyzer

**URL:** <https://discuss.elastic.co/t/regexp-query-and-analyzer/93966>\
**Category:** Elasticsearch\
**Created:** [July 20, 2017, 2:48pm UTC](https://discuss.elastic.co/t/regexp-query-and-analyzer/93966 "2017-07-20T14:48:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefano\_Ghisaura](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefano_ghisaura/32/10476_2.png) [@Stefano\_Ghisaura](https://discuss.elastic.co/u/Stefano_Ghisaura)\
**Post date:** [July 20, 2017, 2:48pm UTC](https://discuss.elastic.co/t/regexp-query-and-analyzer/93966/1 "2017-07-20T14:48:15Z")

</div>

Hi all,  
I've to deal with searches using regex on a string field. I cannot find which is the best (if any) analyzer to be used in this case.  
What I'd need is to search (also) for percentage values like 10.5%, 22.47%, etc... following the pattern provided by the UI, but the search could contain also wildcards to match one or more characters and one or more digits.

Until now I'm testing a custom analyzer defined as:

```
"for-regex-analyzer": {
	"type": "custom",
	"filter": ["decimal_digit"],
	"tokenizer": "whitespace"
}

```

where I used whitespace tokenizer and decimal\_digit filter to be able to look for numbers like "10.5%" (the tokenizer preserve the "%" and the filter prevent the 10.5 to be tokenized as "10" and "5").

Then I should search for something like (e.g.) "share.{1,3} \<0-9\>+._\<0-9\>_%" to match:

- share 1%
- share(s) 12.22%
- shares 90%

Is it correct?

Thank you in advance for any help/idea.

---

<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:** [August 17, 2017, 2:48pm UTC](https://discuss.elastic.co/t/regexp-query-and-analyzer/93966/2 "2017-08-17T14:48:19Z")

</div>

Closed on August 17, 2017, 2:48pm UTC

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