Using StringUtils, you can take a substring from the the beginning of the string to just before the third to last character. A negative index means count back from the end of the String by this many characters.
var idWithSuffix = "123456789098765432_BB";
// This will take a substring from the beginning (index 0), up to the third character from the end of the string.
var idOnly = StringUtils.substring(idWithSuffix, 0, -3);
qie.warn("idOnly = " + idOnly);
// This will take a substring from the third character from the end of the string to the end.
var suffixOnly = StringUtils.substring(idWithSuffix, -3);
qie.warn("suffixOnly = " + suffixOnly);
This prints the following:
idOnly = 123456789098765432
suffixOnly = _BB