Question: I want to split strings in the form of EADGBE or DADF#AD into separate strings, each containing either one letter or one letter plus a # sign. Is there any more elegant way than iterating through the string with a brute-force sort of approach?

String.split obviously relies on delimiters, which are then discarded, which is not much use to me at all - for a couple of minutes there I thought `split("[a-gA-G]#?");` was going to work, but no, that doesn't help at all - I almost want the opposite of that...

Answer: 
Brute force is likely to be your best option, both in terms of code and performance. 

Alternatively, you could use a `Matcher`

```
Pattern p = Pattern.compile("[a-gA-G]#?");
Matcher m = p.march(inputString);
List<String> matches = new ArrayList<String>();
while(m.find())
   matches.add(m.group());

```
Using lookahead and lookbehind works: `String regex = "(?<=.)(?=\\w#?)";`

e.g.,

```
import java.util.Arrays;

public class Foo {
   public static void main(String[] args) {
      String[] tests = {"EADGBE", "DADF#AD"};
      String regex = "(?<=.)(?=\\w#?)";
      for (String test : tests) {
         System.out.println(Arrays.toString(test.split(regex)));
      }
   }
}

```

returns: 

[E, A, D, G, B, E]  

[D, A, D, F#, A, D]