Spaces:
Sleeping
Sleeping
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 | |
} | |
}) | |
} |