The +
operator (quantifier) matches multiple instances of the last character (, character class or capture group or back-reference).
$string = preg_replace('/_+/', '_', $string);
This would replace one or more underscores with a single underscore.
Technically more correct to the title of the question then is to only replace two or more:
$string = preg_replace('/__+/', '_', $string);
Or writing the quantifier with braces:
$string = preg_replace('/_{2,}/', '_', $string);
And perhaps then to capture and (back-) reference:
$string = preg_replace('/(_)1+/', '1', $string);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…