The data is like "abc abc abc (xyz) efg efg".
I am trying to extract the xyz from the string.
Trying to do this in the $project section:
$project: {
bracketextract : { $substr: [ "$title",{ $indexOfCP: [ "$title", "(" ]}, { $indexOfCP: [ "$title", ")" ]} - { $indexOfCP: [ "$title", "(" ]} ]},
}
You should use $subtract to the length (you're using
-currently) and there should be1$add-ed to the starting pointMore readable way using $let: