actually, I believe the checks should be

    // if key has no Control characters
    if (key =~ '^[^\\p{Cntrl}]+$' && key.startsWith(prefix)) {
        // if key cannot be parsed used as property name, does no start with valid char, or contains invalid char
        if (key =~ '^[^a-zA-Z_$]|[ @#%^&§()+-={}\\[\\]~`´<>,."\'/!?:;|]') {