# Using Regex in Kibana Query DSL

**URL:** https://discuss.elastic.co/t/using-regex-in-kibana-query-dsl/303991
**Category:** Elasticsearch
**Tags:** kql-kibana-query-language
**Created:** [May 5, 2022, 5:54am UTC](https://discuss.elastic.co/t/using-regex-in-kibana-query-dsl/303991 "2022-05-05T05:54:32Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![CaMaNi](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@CaMaNi](https://discuss.elastic.co/u/CaMaNi)
#### Post date: [May 5, 2022, 5:54am UTC](https://discuss.elastic.co/t/using-regex-in-kibana-query-dsl/303991/1 "2022-05-05T05:54:33Z")

</div>

Good day everyone,

I am relatively new to the use of Kibana. And I have the following problem:

I want to filter out all numbers and special characters like "\_" or "-" in a field in Discover mode, so that I only have Letters.  
For this I wanted to define a regex via **"+Add filter" -\> "Edit as Query DSL"**. Only the whole thing does not work as thought.

If I now the enter the Regex:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/f/af3e389a5d061563dc87d0dc9900b76eac9fba79.png)

Then there are still values reflected such as "abc-abc-abc-abc". Can someone possibly help me to filter my search correctly?

Thank you! That would be great

PS. I already ask that in the kibana forum, but someone said I should also try it here 🙂

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [May 5, 2022, 6:00am UTC](https://discuss.elastic.co/t/using-regex-in-kibana-query-dsl/303991/2 "2022-05-05T06:00:29Z")

</div>

Linking the other topic - [Using Regex in Kibana Query DSL (filter-option in discover mode)](https://discuss.elastic.co/t/using-regex-in-kibana-query-dsl-filter-option-in-discover-mode/303937)

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [May 5, 2022, 6:59am UTC](https://discuss.elastic.co/t/using-regex-in-kibana-query-dsl/303991/3 "2022-05-05T06:59:40Z")

</div>

Regexes not matching is typically because the searcher assumes the content is what was presented in the original JSON value rather than how this was stored in the index.  
The search matches the tokens stored in the index. You can use the [analyze api](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html) to see how your original value may have been tokenised into multiple tokens.  
You may find [this blog](https://www.elastic.co/blog/find-strings-within-strings-faster-with-the-new-elasticsearch-wildcard-field) helpful in redesigning your index mapping and understanding the matching process

---

<div class="post-metadata">

### Author: ![CaMaNi](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@CaMaNi](https://discuss.elastic.co/u/CaMaNi)
#### Post date: [May 5, 2022, 10:29am UTC](https://discuss.elastic.co/t/using-regex-in-kibana-query-dsl/303991/4 "2022-05-05T10:29:48Z")

</div>

Hi Mark, thanks for the answer. I read the article and tried it. So in the Dev Tools console it works perfectly -\> see screenshot:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/8/c874f8ecf09b200f6b5507d107f8ebc9d5d7ff3b.png)

But as soon I want to implement it into my kibana search it doesn't work.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/7/a7cde2929f6351f4f0148f8bca2a0560b35d7bbb.png)  
I am still not getting the values from type "abc-abc-abc-123"....

But thanks for the good note!

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [May 5, 2022, 3:18pm UTC](https://discuss.elastic.co/t/using-regex-in-kibana-query-dsl/303991/5 "2022-05-05T15:18:09Z")

</div>

I’m not near a computer to check but I suspect Kibana’s filter editor doesn’t require the ‘query’ wrapper

---

<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 2, 2022, 3:18pm UTC](https://discuss.elastic.co/t/using-regex-in-kibana-query-dsl/303991/6 "2022-06-02T15:18:31Z")

</div>

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