File size: 409 Bytes
1ce932e
5916048
 
1ce932e
 
 
 
 
 
 
 
 
 
 
 
5916048
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export const splitStringBracket = (str: string): any[] => {
  // Split string by bracket but keep the bracket
  const result = str.split(/(\{.*?\})/g)
  return result.map((item) => {
    if (item.startsWith('{') && item.endsWith('}')) {
      return {
        editable: true,
        content: item.slice(1, -1),
        key: item,
      }
    } return {
      editable: false,
      content: item
    }
  })
}