This works.
Raw ^.*?/node_modules(?:/(?!react-native-calendars(?=/|$))[^/\r\n]*)*$
Regex literal /^.*?\/node_modules(?:\/(?!react-native-calendars(?=\/|$))[^\/\r\n]*)*$/
It matches all items with the /node_modules
folder and
sets a validation point at every /
to check for the bad folder.
If you are using single item string's, you could remove the (?m)
.
If you want it to be case insensitive, you could add (?i)
if needed.
In JS, you'd add them to the literal syntax /regex/mi
I've already checked this, but if you had some sample input I could link
to an online tester (regex101.com).
Expanded
^ # BOL
.*? # Up until
/node_modules # Required 'node_modules'
(?: # Cluster
/ # / folder start
(?! # Assert cannot be the bad folder
react-native-calendars
(?= / | $ ) # Bad folder end
)
[^/\r\n]* # Ok, get up until start of next folder
)* # Cluster end, do 0 to many times
$ # EOL