This isn't purely a Java question, but I figure I'll throw it out there because it's bugging the heck out of me and maybe someone will get their kicks helping me sort out how to do this. I swear, I should be able to figure this out, but it's a combination of greedy/non-greedy behavior that I just can't wrap my head around.