I am trying to write a RegEx to parse groups of single line comments.
Given this input:
//line 1
//line 2
//line 3
//line 4
//line 5
//line 6
I expect to have two matches: Lines 1-3 and 4-6. With my current RegEx (^\/\/[\S\s]+$) I have one match: Lines 1-6, although there is an empty line in between.
The problem is that \s matches any whitespace character, so the blank line is included. But at the same time, line break are part of the RegEx – but only when the line starts with //, so I am stuck.
How can I prevent the RegEx from matching the blank line?
^\/\/[\S\s]+?\s$