# Regex Match Negative Lookahead

**URL:** <https://community.swiftype.com/t/regex-match-negative-lookahead/689>\
**Category:** General\
**Created:** [April 27, 2018, 9:46pm UTC](https://community.swiftype.com/t/regex-match-negative-lookahead/689 "2018-04-27T21:46:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian.cama](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@brian.cama](https://community.swiftype.com/u/brian.cama)\
**Post date:** [April 27, 2018, 9:46pm UTC](https://community.swiftype.com/t/regex-match-negative-lookahead/689/1 "2018-04-27T21:46:22Z")

</div>

I’m looking to white list all of the pages under a subdirectory but no pages underneath that.

I am attempting to use the following regex match as a whitelist rule with a negative lookahead:

`/page/.+/(?!.+)`

Basically I want to get all the pages under page, but none of the pages that may exist under any of those pages. Is this regex possible? I believe I could do a blacklist for those items but saw that would make indexing slower and while that’s not a deal breaker I was hoping I could just create a clear whitelist rule that would perform the same function.

---

<div class="post-metadata">

**Author:** ![smiller](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@smiller](https://community.swiftype.com/u/smiller)\
**Post date:** [April 30, 2018, 1:10pm UTC](https://community.swiftype.com/t/regex-match-negative-lookahead/689/2 "2018-04-30T13:10:34Z")

</div>

Could you just match any character after /page/ except another slash?  
[^/]+
