It’s not a particularly good place to use regex because the only possible input is a string of arbitrary length containing some combination of four characters in some arbitrary order, using regex will massively overcomplicate the task. You don’t need to find a pattern (which is the purpose of regex), you need to iterate through the characters and do something for each one (which regex is not at all designed to do)