# Use regex to search the text containing dash or minus sign

**URL:** https://discuss.elastic.co/t/use-regex-to-search-the-text-containing-dash-or-minus-sign/211519
**Category:** Elasticsearch
**Created:** [December 11, 2019, 7:52pm UTC](https://discuss.elastic.co/t/use-regex-to-search-the-text-containing-dash-or-minus-sign/211519 "2019-12-11T19:52:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Mihir\_Kothari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mihir_kothari/32/46467_2.png) [@Mihir\_Kothari](https://discuss.elastic.co/u/Mihir_Kothari)
#### Post date: [December 11, 2019, 7:52pm UTC](https://discuss.elastic.co/t/use-regex-to-search-the-text-containing-dash-or-minus-sign/211519/1 "2019-12-11T19:52:33Z")

</div>

Hi,

We have Elasticsearch 6.5. I am using it to search a index using regex and it is working for most of the case.

```
{
  "query": {
		"bool": {
			"must": [
				{
					"match": { "field1:field2" : "Complete" }
				},
				{
					"bool": {
						"should": [
							{
								"regexp": { "field1.field3" : ".*mysource_.+20190102" }
							}
						]
					}
				}
			]
		}
	},
	"size":10000
}

```

Using the above query is running fine for most of the cases. For e.g. _mysource\_121\_AB\_PQ\_20190102_ (and similar) are fetched correctly.  
However, I have a text stored as _mysource\_101\_XY-FG\_20190102_, which is not fetched using the above regex.

If I do not use regex, simple match fetches the data correctly. Only this regex is not working on it. I believe it is due to the hyphen or dash or minus (-) sign.

Can someone help in searching such data using the regex?

Please note the index is not maintained by us, so I cannot run admin commands on index.

---

<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: [January 8, 2020, 7:52pm UTC](https://discuss.elastic.co/t/use-regex-to-search-the-text-containing-dash-or-minus-sign/211519/2 "2020-01-08T19:52:37Z")

</div>

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