The following regex
(\d{3,4})
matches 1234
in
123456
, but since 123456
is longer than 4, I don't want the regex to match anything.
These are my 3 regular expressions that I am using separately, I tried combining them, but it returns more than 2 groups and I just need 2 at the most.
//Match card number before security code
(?<!\d)(\d{13,16})(?!\d)[<""'].*?(?=[>""']\d{3,4}[<""'])[>""'](?<!\d)(\d{3,4})(?!\d)[<""']
//Match card number after security code
(?<!\d)(\d{3,4})(?!\d)[<""'].*?(?=[>""']\d{13,16}[<""'])[>""'](?<!\d)(\d{13,16})(?!\d)[<""']
//Match just card number
(?<!\d)(\d{13,16})(?!\d)