I think you might be better off using the split method in your line (mystring.split ('')) and handle the two cases separately. Regex can be difficult to maintain and read if you have several people updating the code.
if (word.charAt(0) == '#') { if (word.length() == 1) { // use next word } else { // just use current word without the
knutson
source share