"FOO[DOG]".replaceAll("^.*?\\[|\\].*", "");
This will return a string taking only the string inside square brackets.
This remove all string outside from square brackets.
You can test this java sample code online: http://tpcg.io/wZoFu0
You can test this regex from here: https://regex101.com/r/oUAzsS/1