Q:

js regex to match path that starts with X and then not Y

I'd like to match
/.well-known/*

Except
/.well-known/apple-app-site-association

I've tried a few things around
\/\.well-known\/^(?!apple-app-site-association).*

but they don't match strings like
/.well-known/123/erg3rg
/.well-known/

:
var reg = new RegExp(/\/\.well-known\/^(?!apple-app-site-association).*/)
"/.well-known/apple-app-site-association".match(reg) // null :)
"/.well-known/123".match(reg) // null :(

A:

You're on the right track, but you have an extraneous ^. It should be:
\/\.well-known\/(?!apple-app-site-association)
The caret is to match the beginning of the text, so it will never match in the middle of your regex.
Note: the .* at the end was also extraneous, since it would match all the same with or without it.

