When using the regular expression /^\S+\s*$/m.exec("a\nb\n")[0]
, it only returns "a" without including the line delimiter, even though \s
should match \n
.
After some experimentation, I discovered that modifying the expression like this:
/^\S+\s*$\n\r?/m.exec("a\nb\n")[0]
achieves the desired result.
However, this modification creates a regex that is platform-dependent.
Is there a way to include the line delimiting character(s) in the match in a manner that is platform-independent?