I ended up using something similar to the accepted answer, with minor modifications
(^$)|(\s+$)
Explanation by the Expresso
Select from 2 alternatives (^$) [1] A numbered captured group ^$ Beginning of line ^ End of line $ [2] A numbered captured group (\s+$) Whitespace, one or more repetitions \s+ End of line $