I am new to regexs. I have this :
'@time-transform{
[bg:red;c:white]
[bg:black]
[bg:white;c:black]
}'
I want the part inside curly brackets.
CodePudding user response:
You can split the string by regex:
const result = input.split(/({|})/)[2];
CodePudding user response:
Seems it can be also done without regex tho.
const text = '@time-transform{[bg:red;c:white][bg:black][bg:white;c:black]}';
const result = text.substring(text.indexOf('{') 1, text.indexOf('}'));
console.log(result);
// logged: '[bg:red;c:white][bg:black][bg:white;c:black]' (string)