{"id":"code-work-sb-regex-order-numbers","audience":"small-business","category":"coding","track":"coding","technique":"examples","title":"Pull order numbers out of customer messages","free":false,"task":"Write one Google Sheets formula for B2 (filled down) that finds the order number in the customer message in A2. Customers type it as ck-10422, CK 10422, #CK10422 and so on; order numbers are CK plus exactly 5 digits. Always return it in one format, like CK-10422 (capitals, hyphen). If there's no order number, show NO ORDER #. One formula in one code block, then under 25 words outside the code.","materialLabel":"Customer messages from the shop inbox (attached to your prompt automatically)","material":"INBOX EXPORT - Copper Kettle Candle Co., last week (row 1 is headers)\nA Message | B Order # | C Received\n\"hi my order ck-10422 never showed up :(\" | ? | Mon\n\"Order #CK10431 - the lid was cracked\" | ? | Mon\n\"can I change the scent on CK 10440 before it ships?\" | ? | Tue\n\"Do you do wholesale? We run a gift shop in Bend.\" | ? | Tue\n\"re: CK-10398, still waiting on a tracking number\" | ? | Wed\n\"loved the cedar candle!! will order again\" | ? | Thu\n\nNotes from Bea:\n- We answer about 40 messages a week.\n- Order numbers started at CK-10000 in January.\n- The shop platform can look up an order only when it's typed exactly CK-10422.\n- Wholesale questions go to Sam.\n- Phone numbers sometimes show up in messages too.","rules":[{"type":"codeBlocks","count":1},{"type":"maxProseWords","max":25}],"mistakes":[{"title":"Not showing the messy versions","why":"The AI matches only one spelling, like CK-10422, and misses the rest.","fix":"Add examples: \"ck-10422, CK 10422, #CK10422 are all the same.\"","checks":["r0"]},{"title":"Not showing the output format","why":"The AI returns whatever the customer typed, which your shop can't look up.","fix":"Add: \"Always return it like CK-10422.\"","checks":["r1"]},{"title":"Leaving no-match open","why":"Messages without a number show #N/A.","fix":"Add: \"If there's none, show NO ORDER #.\"","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 messy versions","patterns":["ck 10422","#ck","ck-?10422","any case|capital"]},{"label":"Shows the output format","patterns":["ck-\\d{5}","always return","one format"]},{"label":"Handles no match","patterns":["no order","none|not found"]},{"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 the different ways customers type the number and the one way you need it back.","rubricLabels":["Finds CK followed by 5 digits whatever the case and whatever sits between them (nothing, a space, a hyphen), for example REGEXEXTRACT(UPPER(A2), \"CK[ #-]*(\\d{5})\") or a (?i) flag","Always returns the number as CK-##### with capitals and a hyphen, so \"CK 10440\" gives CK-10440","Returns the exact text NO ORDER # when no order number is found (for example with IFERROR or IFNA)"]}