# Cannot match special characters in regular in ES 7.x

**URL:** <https://discuss.elastic.co/t/cannot-match-special-characters-in-regular-in-es-7-x/224369>\
**Category:** Elasticsearch\
**Created:** [March 20, 2020, 7:46am UTC](https://discuss.elastic.co/t/cannot-match-special-characters-in-regular-in-es-7-x/224369 "2020-03-20T07:46:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SparkHex](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@SparkHex](https://discuss.elastic.co/u/SparkHex)\
**Post date:** [March 20, 2020, 7:46am UTC](https://discuss.elastic.co/t/cannot-match-special-characters-in-regular-in-es-7-x/224369/1 "2020-03-20T07:46:30Z")

</div>

Trying to use regexp matching a value like **xxx.php** ，i write the following code.And I also found many ways for me to escape with double backslashes, but it doesn't work either.I guess it should be a version issue.

```auto
GET /log.XXXX/_search
{
    "query": {
        "regexp": {
            "uri_path": "@(\\.php)"
        }
    }
}

```

Of course, the following code can match the result I want, but I think that **@** matches the special character **.**

```auto
GET /log.XXXX/_search
{
    "query": {
        "regexp": {
            "uri_path": "@(php)"
        }
    }
}

```

So sincerely hope to get your suggestions

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 20, 2020, 9:16am UTC](https://discuss.elastic.co/t/cannot-match-special-characters-in-regular-in-es-7-x/224369/2 "2020-03-20T09:16:33Z")

</div>

Hey

can you share the mapping for this field and provide a **fully fledged** example? I suppose your field is already analyzed & tokenized and there this approach does not work. Have you tried to just search for `php` as well?

---

<div class="post-metadata">

**Author:** ![SparkHex](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@SparkHex](https://discuss.elastic.co/u/SparkHex)\
**Post date:** [March 20, 2020, 1:41pm UTC](https://discuss.elastic.co/t/cannot-match-special-characters-in-regular-in-es-7-x/224369/3 "2020-03-20T13:41:47Z")

</div>

thx,i got it.I can’t match because of the word segmentation, just change to the keyword type, which is uri\_path.keyword

---

<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:** [April 17, 2020, 1:41pm UTC](https://discuss.elastic.co/t/cannot-match-special-characters-in-regular-in-es-7-x/224369/4 "2020-04-17T13:41:49Z")

</div>

Closed on April 17, 2020, 1:41pm UTC

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