Regex for IBAN mask

后端 未结 4 1100
心在旅途
心在旅途 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:00

    The problem in your regex101 demo is, there is an extra character in your regex after $ so remove that and change 0 to [0 ] and this fixes all and starts matching your third line too. The correct regex becomes,

    NL\s?\d{2}\s?[A-Z]{4}[0 ]\s?\d{9}$
    

    Check your updated demo

提交回复
热议问题