I have following regex to validate card number
[\d+]{6,6}[X|x]{8,8}[\d+]{4,4} I want to validate following as valid card number
123456XXXXxxxx1234 But anything extra then this should not match.
123456XXXXxxxx1234a bbb123456XXXXxxxx1234nnn That is these should not match.
I tried this regular expression but it is not working for me.
^[\d+]{6,6}[X|x]{8,8}[\d+]{4,4}$
[\d+]{4,4}matches 4 digits or plus symbols. I think you just meant\d{4}(4 digits). Right? Also:[X|x]{8,8}matches 8X,xor|symbols. I guess you need just[Xx]{8}.