# Am I right in thinking Lucene regex doesn't support lookahead?

**URL:** https://discuss.elastic.co/t/am-i-right-in-thinking-lucene-regex-doesnt-support-lookahead/346882
**Category:** Kibana
**Created:** [November 10, 2023, 4:02pm UTC](https://discuss.elastic.co/t/am-i-right-in-thinking-lucene-regex-doesnt-support-lookahead/346882 "2023-11-10T16:02:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dmgeurts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dmgeurts/32/95115_2.png) [@dmgeurts](https://discuss.elastic.co/u/dmgeurts)
#### Post date: [November 10, 2023, 4:02pm UTC](https://discuss.elastic.co/t/am-i-right-in-thinking-lucene-regex-doesnt-support-lookahead/346882/1 "2023-11-10T16:02:41Z")

</div>

Creating a new visualisation I just came across a curious case of regex filtering.

The following Regex Lucene filter is what I had to use to show only values containing both upper and lower caps:

**Works**  
`dns.question.name:/.*[A-Z].*/ and NOT (dns.question.name:/.*[A-Z].*/ and NOT dns.question.name:/.*[a-z].*/)`

It looks pretty convoluted, but it must be done this way to not match entries in all lower- or all uppercase. The following would be simpler from a regex point of view but doesn't work. Presumably due to the lookahead?

**Doesn't work**  
`dns.question.name:/(?=.*[a-z])(?=.*[A-Z]).*/`

---

<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: [December 8, 2023, 4:02pm UTC](https://discuss.elastic.co/t/am-i-right-in-thinking-lucene-regex-doesnt-support-lookahead/346882/2 "2023-12-08T16:02:57Z")

</div>

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