使substring()方法忽略某些字符

I want to create an animation that builds a string by always appending one more char. Like: 'H', 'He', 'Hel', 'Hell', 'Hello' For this, I've already created a simple method:

Collection<String> states = new ArrayList<>();
    String text = "§aTest §bTest2";
    for (int i = 0; i < text.length(); i++) {
      states.add(text.substring(0, i));
    }

But as you can see, the string can also contain chars that are invisible for the user later (like §a and §b). Adding them to the animation states using the above method would look very strange because there are 2 states which have no visible change, which makes the animation glitch. For example the user sees: '', '', 'T', 'Te', 'Tes', 'Test', 'Test ', 'Test ', 'Test ', 'Test T'

但是它们对于颜色很重要,并且可能无法删除,因为那样就不会有颜色。

那么,在构建子字符串时如何将这些字符忽略而不真正从字符串中删除呢?