//MongoDB version on windows(actual code output from mongo shell 4.2 on windows)
> db.version();
4.2.6
//prepare the same data and query it as below, per problem statement
> db.test5.find()
{ "_id" : ObjectId("5f721b8a3d04e9033d482a9b"), "id" : "id-1", "blocked" : [ "abcd.com/[a-z]+", "efgh.com/[0-9]+" ] }
{ "_id" : ObjectId("5f721b8a3d04e9033d482a9c"), "id" : "id-2", "blocked" : [ "pqrs.com/[w]+", "xyz.com/[.]+" ] }
declare variables to include the string for which regex can be checked from collection
> var1 = "abcd.com/mongodb";
abcd.com/mongodb
> var2 = "google.com/mongo";
google.com/mongo
//actual code output from mongo shell using aggregate
//you need to use $regexMatch to match the variable string to that is stored in the collection
> db.test5.aggregate([
... {$unwind:"$blocked"},
... {$addFields:{result1:{$regexMatch:{input:var1,regex:"$blocked"}}}},
... {$addFields:{result2:{$regexMatch:{input:var2,regex:"$blocked"}}}}
... ]);
{ "_id" : ObjectId("5f721b8a3d04e9033d482a9b"), "id" : "id-1", "blocked" : "abcd.com/[a-z]+", "result1" : true, "result2" : false }
{ "_id" : ObjectId("5f721b8a3d04e9033d482a9b"), "id" : "id-1", "blocked" : "efgh.com/[0-9]+", "result1" : false, "result2" : false }
{ "_id" : ObjectId("5f721b8a3d04e9033d482a9c"), "id" : "id-2", "blocked" : "pqrs.com/[w]+", "result1" : false, "result2" : false }
{ "_id" : ObjectId("5f721b8a3d04e9033d482a9c"), "id" : "id-2", "blocked" : "xyz.com/[.]+", "result1" : false, "result2" : false }
>
//the result will be true or false boolean.
//Hope, you can use this result to process your further logic of return array or empty string
//eg. case1 per your requirements: Since var1 matches with string it matches to true
//similarly case2 per your requirements: Since var2 does not match it returns false