Вариант для примеров посложнее, но только плюс и минус.
$str = "7-67+345+876+86+7-67-56787+7898+6787+56789"
$len = 1
arrpush($sign, 0)
WHILE($len > 0)
$len = STRPOS ($str, "+", $len)
IF($len > 0)
arrpush($sign, $len)
$len = $len+1
END_IF
END_CYC
$len = 1
WHILE($len > 0)
$len = STRPOS ($str, "-", $len)
IF($len > 0)
arrpush($sign, $len+0.00004)
$len = int($len+1)
END_IF
END_CYC
arrpush($sign, STRLEN ($str)+1)
ARRSORT ($sign)
$num = STRCUT2($str, int($sign[$a])+1, int($sign[$a+1])-1)
FOR($a=1,$a<arrsize($sign)-1)
IF(int($sign[$a])<$sign[$a])
$num = $num - STRCUT2($str, int($sign[$a])+1, int($sign[$a+1])-1)
else
$num = $num + STRCUT2($str, int($sign[$a])+1, int($sign[$a+1])-1)
END_IF
END_CYC
print("ответ: ", $num)
halt