# How to escape special characters in regexp

**URL:** <https://discuss.elastic.co/t/how-to-escape-special-characters-in-regexp/245727>\
**Category:** Elasticsearch\
**Created:** [August 20, 2020, 8:17am UTC](https://discuss.elastic.co/t/how-to-escape-special-characters-in-regexp/245727 "2020-08-20T08:17:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krishna\_Sai\_Nag\_G](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krishna_sai_nag_g/32/80467_2.png) [@Krishna\_Sai\_Nag\_G](https://discuss.elastic.co/u/Krishna_Sai_Nag_G)\
**Post date:** [August 20, 2020, 8:17am UTC](https://discuss.elastic.co/t/how-to-escape-special-characters-in-regexp/245727/1 "2020-08-20T08:17:03Z")

</div>

How to escape special characters in regular expression query

GET my\_index/\_search  
{

"\_source": ["file.filename"],  
"query": {  
"regexp": {  
"content": "KRISHNA\-\1H3[a-zA-Z0-9]\*"  
}  
},  
"highlight": {  
"fields": {  
"content": {}  
}  
}  
}

---

<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 17, 2020, 8:17am UTC](https://discuss.elastic.co/t/how-to-escape-special-characters-in-regexp/245727/2 "2020-09-17T08:17:13Z")

</div>

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