db.collection_name.aggregate([
{$match: {"target_field": {$exists: true}}},
{$addFields: {
"remove": {$regexFind: {
input: "$target_field",
regex: /(.){1,}string_to_match/
}}
}},
{$match: {"remove": {$exists: true} }},
{$addFields: {
"remove_len": {$strLenBytes: "$remove.match"}
}},
{$addFields: {
"clean": {$substr: [
"$target_field",
"$remove_len",
100000]}
}},
])
No comments:
Post a Comment