Regex to match square brackets at end of string