What a masked message looks like
The last four digits are kept so the office can still say “the card ending 4242”. A security code is masked when it follows words like “cvv” or “security code”, and an expiry when it follows words like “expiry” or “valid thru”; both are also caught when dictated right after a card number.
How the engine decides a number is a card
A phone number or an invoice number must be left alone, so a run of 13 to 19 digits counts as a card only when both of these hold:- it passes the checksum every real card number passes, and
- it is written as four groups of four, or there are payment words nearby, such as “visa”, “credit card”, “card number”, “expiry” or “cvv”.