How to capture css rule block in a string?
This is too hard for me to capture, without the new line
.fa { color: red; }
small { font-size: 16px; }
#content { background-color: blue; }
What I want to accomplish is to get each those block into array
['.fa { color: red; }', 'small { font-size: 16px; }', '#content { background-color: blue; }']
Is this possible in javascript regex?
UPDATE
Sorry guys, I Thought this is only solvable with regex,
But got an answer which is way simpler, Thanks
>Solution :
Split by a closing curly brace:
const str = `.fa { color: red; }
small { font-size: 16px; }
#content { background-color: blue; }
`
const res = str.split("}").map(e => e += "}")
console.log(res)