Library › Coding AI › Customer support teams
Mask card numbers in ticket text before sharing
Practice: Setting limits and rules. About 5 minutes.
About this exercise
Before the ticket log goes to the product team, card numbers customers pasted must be masked. Write one Google Sheets formula for B2 (filled down) that replaces any 13- to 16-digit card number in A2, even with spaces or dashes between groups, with **** plus its last 4 digits (like **** 4242). Order numbers like CK-10422 and 10-digit phone numbers must stay as they are. One formula in one code block, then under 25 words outside the code.
Common mistakes when you ask AI for this
- Not mentioning spaces and dashes. The AI matches 16 digits in a row and misses 4111 1111 1111 4242. Try: Add: "Card numbers may have spaces or dashes between groups."
- Not showing the mask. The AI blanks the number or hides all of it, so support can't match the card. Try: Add: "Replace with **** and the last 4, like **** 4242."
- Masking too much. A loose pattern also hides phone and order numbers. Try: Add: "Only 13-16 digit numbers; leave CK-10422 and phone numbers alone."
- Getting a menu of options. The AI likes to offer two or three versions of the formula, so you're left to pick and test them yourself. Try: Add: "Give one formula only, in one code block, no alternatives."
- Getting a tutorial. By default the AI explains every part of the code at length, which you then have to scroll past. Try: Add: "After the code, one line under 10 words. Nothing else."
What a strong prompt includes
- Mentions spaces and dashes
- Shows the mask
- Protects other numbers
- Asks for one answer only
- Limits the explanation
Related exercises
- Add a cron line that matches the others in a crontab (Coding AI · Product managers)
- Add dark mode by overriding your existing CSS variables (Coding AI · Software developers)
- Add input checks to your number guessing game (Coding AI · High school students)
- Add input validation to a Java method with exact messages (Coding AI · Software developers)
- Add labels to a signup form without rewriting the page (Coding AI · High school students)