Reputation: 44526
I'm trying to match file paths that start with any string from a list. This is what I am using for that:
^/(dir1|dir2|dir3|tmp|dir4)/
I'm also trying to match all paths that start with /tmp/
but do not contain special
after that.
This should match:
/tmp/subdir/filename.ext
But this should not:
/tmp/special/filename.ext
I can't seem to find a way to get this done. Any suggestions would be greatly appreciated.
Upvotes: 14
Views: 23009
Reputation: 2047
Try ^(?i)/(dir1|dir2|dir3|tmp(?!\/(special))|dir4)/.*
(?i)
= Case insesitivity this will match SpEcial, SPECial, SpEcIAL etc.
(?!\/(special))
= Negative lookahead for the '/special'
Upvotes: 9