So I have this string:
function abc() {\n\n return def;\n}
And I use this:
string.match(/[^\r\n]+/g)
And it matches into 3 lines:
Match 1: function abc() {
Match 2: return def;
Match 3: }
But it is missing a fourth match which should be the new line with no characters after the '{'.
I am using the website https://regex101.com/r/ALvFIN/1/ to test.
Set to flavor: ECMAScript
Regex: /[^\r\n]+/g
Test String:
function abc() {
return def;
}
Any idea how to correctly match the double \n\n with no characters on line 2? I have tried the whitespace \s and \S but not right. Starting to think I need to look at an alternative solution.