The patterns should be a little more assertive, which means that the look should state that the next position is either a word character or # does not matter, and in lookahead you must say that the previous position is either a # character.
You can use word boundaries in each rotation:
String s = "#stack###over##flow"; String[] a = s.split("(?<=#\\b)|(?=\\b#)"); System.out.println(Arrays.toString(a));
Or modify your search statements (longer approach):
String[] a = s.split("(?<=#(?!#))|(?<=[^#](?=#))");
source share