If you are writing configuration to take a pattern to match against files in a file system…
You probably want Dir.globs, not regexes. Dir.glob is in the stdlib. Dir.glob’s unix-shell-style patterns are less expressive than regexes, but probably expressive enough for anything you need in this use case, and much simpler to deal with for common patterns in this use case.
…I don’t even feel like thinking about how to express as a regexp that you don’t want child directories, but only directly there.
Dir.glob will find matches from within a directory on local file system — but if you have a certain filepath in a string you want to test for a match against a dirglob, you can easily do that too with Pathname.fnmatch, which does not even require the string to exist in the local file system but can still check it for a match against a dirglob.
Some more info and examples from Shane da Silva, who points out some annoying inconsistent gotchas to be aware of.