Changing the foreground and background colors of substrings based on ANSI escape codes
You can do it a little more generic but I'm afraid you still have to test each.

I don't know if your case is always changing to green or not.
If not I suggest the following enum :

/**
 *
 * @author chillworld
 */
public enum ColorMapperEnum {
    GREEN("[30;42m",Color.GREEN) ,
    RED("[31;42m",Color.RED) ,
    BLACK("[32;42m", Color.BLACK) ,
    BLUE("[33;42m", Color.BLUE); // and so on

    private String textToFind;
    private Color targetColor;

    private ColorMapperEnum(String textToFind, Color targetColor) {
        this.textToFind = textToFind;
        this.targetColor = targetColor;
    }

    public String getTextToFind() {
        return textToFind;
    }

    public Color getTargetColor() {
        return targetColor;
    }
}


Now you can do a whole lot more generic in your java code :

for (ColorMapperEnum colorMapper : ColorMapperEnum.values()) {
    if(string.contains(colorMapper.getTextToFind()){
        index = string.indexOf(colorMapper.getTextToFind()); 
        string = string.replaceAll("\\" + colorMapper.getTextToFind(), "");
        backgroundColor = colorMapper.getTextToFind();
    }
 }


I did use the same naming as yo but I advice to take better naming.
String string => very bad, for what stands it?

Now I don't know if there could be a case that multiple conditions are true and what there must be done when multiple conditions are true.

An enum values() has always the same result in the same order.
Use that in your advantage when tackling that problem.