Q:

Regex to match URLs with files not in the root or one specified folder

I'm trying to come up with a regular expression that will match on all folders on a website except for files that are in the root folder or one specific folder that I specify. 
I'm working in a restricting GUI environment that implements it in Javascript/PERL so there are some considerations:

It's not important that I match on the entire URL, just a portion of it. 
\K is not supported
I can't use the results of groupings

Here are some examples:
Don't match on files in the root directory OR files in one specified folder, like:

example.com/index.html

example.com/dontmatchonme/

Match on all other files/folders:

example.com/matchonthisfolder/test

example.com/matchonanyotherfolder/index.html

I can use example.com/(?!dontmatchonme/) to match on everything that is not in this specific folder but then I lose my matches on any files in the root folder (which I want to keep). 
I really appreciate any advice or techniques that could help me solve this issue in one regular expression. 

A:

^example.com\/(?!dontmatchonme\/).*\/

^example.com matches the "site root"
(?! dontmatchonme\/) is a zero width negative lookahead assertion to not match "dontmatchonme"
.*\/ ensures that the rest of the path has an extra / in it, which shows that it is not in the root folder

In this example I have escaped / characters with a backslash \ because that's the way it works in perl.   You will probably need to omit this

