Say you want to search for a certain string, but exclude files which match another pattern.
PATTERN_TO_EXCLUDE="bad.+words"
DIR_TO_SEARCH=foo/bar
PATTERN_TO_FIND="good.+good"
rg $PATTERN_TO_FIND --stats $(rg $PATTERN_TO_EXCLUDE --files-without-match $DIR_TO_SEARCH)