{"id":"code-work-office-regex-phone-format","audience":"office","category":"coding","track":"coding","technique":"examples","title":"Standardize messy phone numbers with one regex formula","free":false,"task":"The vendor list in column A has phone numbers typed every possible way. Write one Google Sheets formula for B2 (filled down) that strips everything but digits, keeps the last 10 digits so a leading 1 or +1 is dropped, and formats them like 503-555-0142 (hyphens, no parentheses), because the phone system import rejects anything else. If fewer than 10 digits remain, show CHECK. One code block, then under 25 words outside the code.","materialLabel":"Vendor phone column (attached to your prompt automatically)","material":"VENDORS sheet - facilities contacts (row 1 is headers)\nA Phone | B Clean phone | C Vendor | D Service\n(503) 555-0142 | ? | Brightline Cleaning | Nightly cleaning\n503.555.0199 | ? | Kopa Office Supply | Paper, toner\n+1 503 555 0110 | ? | Alder HVAC | Heating repair\n1-503-555-0177 | ? | Fleetline Couriers | Same-day courier\n555-0123 | ? | Rosa's Catering | Lunch orders\n503 555 0188 ext 4 | ? | Ridge Elevator | Elevator service\n\nNotes from Hal (facilities):\n- The list goes into the new phone system next week.\n- Rosa's number is missing its area code; I'll call her.\n- Ridge Elevator's extension 4 is the after-hours line.\n- Brightline also has an emergency number on the fridge.\n- About 90 vendors in total.","rules":[{"type":"codeBlocks","count":1},{"type":"maxProseWords","max":25}],"mistakes":[{"title":"Not showing the target format","why":"The AI picks its favorite format, often (503) 555-0142, which the import rejects.","fix":"Add an example: \"Format like 503-555-0142, hyphens only.\"","checks":["r1"]},{"title":"Forgetting the country code","why":"The AI keeps the leading 1, so some numbers end up 11 digits long.","fix":"Add: \"Keep only the last 10 digits.\"","checks":["r0"]},{"title":"Not saying what to do with short numbers","why":"The AI returns a broken number or an error for 555-0123.","fix":"Add: \"Fewer than 10 digits: show CHECK.\"","checks":["r2"]},{"title":"Getting a menu of options","why":"The AI likes to offer two or three versions of the formula, so you're left to pick and test them yourself.","fix":"Add: \"Give one formula only, in one code block, no alternatives.\"","checks":["codeBlocks"]},{"title":"Getting a tutorial","why":"By default the AI explains every part of the code at length, which you then have to scroll past.","fix":"Add: \"After the code, one line under 10 words. Nothing else.\"","checks":["maxProseWords"]}],"promptHints":[{"label":"Shows the target format","patterns":["\\d{3}-\\d{3}-\\d{4}","hyphens?","format like"]},{"label":"Drops the country code","patterns":["last 10","10 digits","country code","\\+1"]},{"label":"Handles short numbers","patterns":["check","fewer than","less than 10"]},{"label":"Asks for one answer only","patterns":["\\b(one|single|1)\\s+(formula|code block|block|version)","only one","no (alternatives|options|other versions)"]},{"label":"Limits the explanation","patterns":["\\d+\\s*words","no (explanation|notes|commentary)","one (short )?(line|sentence)","nothing else"]}],"hint":"Show the AI one finished number so it copies your format, and say what happens to numbers that are too short.","rubricLabels":["Removes every non-digit with REGEXREPLACE (such as \"\\D\" or \"[^0-9]\") and keeps the last 10 digits (for example RIGHT(...,10)), so +1 503 555 0110 becomes 503-555-0110","Formats the result as three groups joined by hyphens with no parentheses, like 503-555-0142","Shows the text CHECK when fewer than 10 digits remain (so 555-0123 shows CHECK)"]}