Regex for IBAN mask

后端 未结 4 1102
心在旅途
心在旅途 2021-01-22 05:18

I am trying to extract this text \"NL dd ABNA ffffdffffdffffd\" from string:

IBAN NL 91ABNA0417463300
IBAN NL91ABNA0417164300
Iban: NL 69 ABNA 402032566
4条回答
  •  悲哀的现实
    2021-01-22 06:10

    You can just remove all spaces and uppercase the rest, Like this:

    iban = NL 91ABNA0417463300
    iban.replace(" ", "")
    iban.upper()
    

    And then your regex would be:

    NL\d{2}ABNA(\d{10}|\d{9})
    

    It works in https://regex101.com/r/zGDXa2/1

提交回复
热议问题