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.24,2021

  var a='1232{1}{2}765432'
    console.log(a.replace(/{/,',{').replace(/}/g,'},').split(','),'9999');

output


For example,
1232 {Button 1} {Button 2} 765432 then / ^ (\ d +) (\ {Button\ d\}) (\ {Button\ d\}) (\ {Button\ d\}) (\ d+) (\ d+) $/ can get each part from the captured submatches. For example,

var re=/^(\d+)(\{\d\})(\{\d\})(\d+)$/;
var rtall=re.exec("1232{1}{2}765432");
console.log(rtall);

let str = "1232{1}{2}765432"
function trans (str) {
  let count = 0
  let matched = []
  let subStr = ''
  for (let i = 0, len = str.length; i < len; iPP) {
    let cur = str[i]
    if (cur === '{') {
      if (count === 0) {
        if (subStr.length) matched.push(subStr)
        subStr = cur
      } else {
        subStr += cur
      }
      countPP
    } else if (cur === '}') {
      subStr += cur
      count--
      if (count === 0) {
        matched.push(subStr)
        subStr = ''
      }
    } else {
      subStr += cur
    }
  }
  if (subStr.length) matched.push(subStr)
  return matched
}
trans(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-1eb34b2-48206.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-1eb34b2-48206.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?