Reputation: 288
Hoping someone can point me in the right direction with this. I'm making a little Grunt task that requires some CSS be split up using regex.
Here is an example of the regex in question working as expected:
https://regex101.com/r/gY6zO7/1
For some reason however, when I run this as part of my grunt task it crashes terminal.
var regexString = new RegExp("^((?:\.|#)(?:[a-z]|[A-Z]|[0-9]|\s|\.|#|-|:|&|,)+?{(?:\s|\n)*(?:\/\*export\*\/)(?:.|\n)*?})", "gm");
var splitString = css.split(regexString);
I've tried countless variations but I can't seem to figure out what exactly is going on, any help appreciated!
Upvotes: 0
Views: 134
Reputation: 175766
You need to escape the backslashed \s
and \n
to \\s
and \\n
as they are inside a string (or use the unquoted //
syntax).
Upvotes: 1