I need to check an input field for a German IBAN. The user should be allowed to leave in white spaces and input should be validated to have a starting DE
DE
Most simple solution I can think of:
^DE(\s*[[:alnum:]]){20}\s*$
In particular, your initial [DE]{2} is wrong, as it allows 'DD', 'EE', 'ED' as well as the intended 'DE'.
[DE]{2}