How to intercept irregular strings

for example, I have a dynamic string like 1232 {Button 1} {Button 2} 765432 (variable length). How can I get 1231 and {Button 1}, {Button 2}, 765432?

Mar.19,2021

const str = "1232{1}{2}765432";
function handleStr(str) {
  const result = [];
  //
  let inBraceNow = false;
  for (let i = 0; i < str.length; iPP) {
    const currentChar = str[i];
    if (inBraceNow) {
      result[result.length - 1] += currentChar;
      if (currentChar == "}") {
        inBraceNow = false;
      }
    } else {
        //"{"...
      if (currentChar == "{") {
        result.push("{");
        inBraceNow = true;
      } else {
          // result
          //0
        if (result.length == 0||(!+result[result.length-1])) {
          result.push(0);
        }
        result[result.length - 1] =10*result[result.length - 1]+(+currentChar);
      }
    }
  }
  return result;
}
console.log(handleStr(str));
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c1fd59-334aa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c1fd59-334aa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?