Regex for IBAN allowing for white spaces AND checking for exact length

后端 未结 7 2218
盖世英雄少女心
盖世英雄少女心 2020-12-08 22:56

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

7条回答
  •  春和景丽
    2020-12-08 23:42

    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'.

提交回复
热议问题