You have probably heard of Earnshaw’s theorem which says levitation with magnets is not possible under certain conditions and assumptions. One of the assumptions is no exernal forces, which is violated by your string, so we cannot apply Earnshaw’s theorem.
A little bit of experimentation with two equal size magnets suggests to me that if there is the slightest asymmetry in centering the axis of the two magnets, the magnets experience a moment which tends to flip them.
Can the string provide a reaction moment to prevent flip?
Probably not if it is simply attached from a point in the center of the face of one magnet to a point on center of face of the other magnet. There may be other configurations such as multiple loops of string that might work.
=====================================
(2B)+(2B)' ?