# Kibana Regexp Filter Error Unexpected '.'

**URL:** https://discuss.elastic.co/t/kibana-regexp-filter-error-unexpected/146569
**Category:** Kibana
**Created:** [August 29, 2018, 5:59pm UTC](https://discuss.elastic.co/t/kibana-regexp-filter-error-unexpected/146569 "2018-08-29T17:59:25Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![caklier](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@caklier](https://discuss.elastic.co/u/caklier)
#### Post date: [August 29, 2018, 5:59pm UTC](https://discuss.elastic.co/t/kibana-regexp-filter-error-unexpected/146569/1 "2018-08-29T17:59:26Z")

</div>

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

I am trying to create a filter than only shows page urls that have an extension. pagename.keyword:/.\*.[^./]+/ works fine when I enter it into the search bar but I can't seem to find the right way to enter it as a filter in Query DSL using the regexp plugin. I'm getting an error that says "Unexpected '.'"  
The reason I am using the .keyword is so that the whole url will be searchable instead of just specific terms.

---

<div class="post-metadata">

### Author: ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)
#### Post date: [August 30, 2018, 11:31am UTC](https://discuss.elastic.co/t/kibana-regexp-filter-error-unexpected/146569/2 "2018-08-30T11:31:02Z")

</div>

Hey @caklier,

Try surrounding your regex in quotes:

```auto
{
   "query": {
      "regexp": {
          "pageurl.keyword": ".*......"
       }
   }
}

```

---

<div class="post-metadata">

### Author: ![caklier](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@caklier](https://discuss.elastic.co/u/caklier)
#### Post date: [August 30, 2018, 5:02pm UTC](https://discuss.elastic.co/t/kibana-regexp-filter-error-unexpected/146569/3 "2018-08-30T17:02:56Z")

</div>

Putting quotes around the regex gives an error that says "bad string."

---

<div class="post-metadata">

### Author: ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)
#### Post date: [August 30, 2018, 5:21pm UTC](https://discuss.elastic.co/t/kibana-regexp-filter-error-unexpected/146569/4 "2018-08-30T17:21:44Z")

</div>

You may have to double-escape the expression. Try:

```json
{
  "query": {
    "regexp": {
      "pageurl.keyword": ".*\\.[^\\.\\/]+"
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![caklier](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@caklier](https://discuss.elastic.co/u/caklier)
#### Post date: [August 31, 2018, 4:37pm UTC](https://discuss.elastic.co/t/kibana-regexp-filter-error-unexpected/146569/5 "2018-08-31T16:37:13Z")

</div>

Thank you, this worked. Could you please explain why there is a need to double escape the expression? I didn't read about this in any of the forums or documentation that I have come across so far so any clarification would be great.

---

<div class="post-metadata">

### Author: ![caklier](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@caklier](https://discuss.elastic.co/u/caklier)
#### Post date: [August 31, 2018, 6:44pm UTC](https://discuss.elastic.co/t/kibana-regexp-filter-error-unexpected/146569/6 "2018-08-31T18:44:47Z")

</div>

At first I thought that your solution worked since the filter accepted this format. However, the filter doesn't work as I intended. If I click "exclude matches" on the filter, I still get some pageurls that SHOULD match the filter. For Example, /index.xhtml and /client/chat.php appear as not matching the original filter when they should as they are page urls with an extension. Could you help me fix my regex to include all page urls with extensions?

---

<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: [September 28, 2018, 6:45pm UTC](https://discuss.elastic.co/t/kibana-regexp-filter-error-unexpected/146569/7 "2018-09-28T18:45:11Z")

</div>

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