Websites, apps & code / Coding & debugging

Write a text pattern (regex)

Find phone numbers, dates or codes inside a pile of text.

Fill in your details

Leave blank to use the example. Names are remembered for other prompts too (stored only on your device).

Variation:Where to use

Prompt

Please write a text pattern (regular expression) for me.

What to find: Malaysian mobile numbers: 012-345 6789, 0123456789, +6012-3456789
What must not match: Landlines like 07-123 4567
Where I will use it: Use functions such as REGEXMATCH or REGEXEXTRACT.

Please:
1. Give the pattern, then explain it in small pieces in plain words.
2. Give a test table: 5 examples that should match and 5 that should not, so I can check.
3. Point out what it might miss or wrongly catch.
4. Explain how to use it where I chose, step by step.
5. Use fake numbers in examples and do not ask me to paste real customer data.

Paste it into ChatGPT, Gemini, Claude or Meta AI.

Test result

Run on 2026-12-01 with Claude Sonnet 5.5 (variation: Google Sheets), using the example details above. AI never answers word for word the same twice, but the shape stays close.

What we noticed

The AI gave the pattern, a plain explanation and a 5 plus 5 test table, and admitted 011 numbers with 11 digits are missed. The pattern was not run in real Google Sheets, so you should check it against the table yourself.

See what the AI actually wrote

Rule first, then the explanation. I am using Google Sheets' REGEXMATCH / REGEXEXTRACT (RE2 syntax).

The pattern (assuming the number is already text):

^(?:\+?60|0)1\d[- ]?\d{3}[- ]?\d{4}$

This accepts 10-digit mobile numbers (the 012-xxx xxxx type). If you also want 11-digit numbers starting 011 (like 011-1234 5678), it needs loosening; see "might miss" below.

In plain words:

  • ^ and $: the whole string must fit, with nothing else before or after.
  • (?:\+?60|0): starts with "+60" or "60", or with "0".
  • 1\d: then a 1 and one more digit (the 012, 013, 016, 017, 019 mobile prefixes). Landlines start with 07, so they naturally fail here.
  • [- ]?: there may be one dash or one space, or neither.
  • \d{3}, \d{4}: 3 digits and 4 digits.

Test table (fake numbers):
Should match:

  1. 012-345 6789
  2. 0123456789
  3. +6012-3456789
  4. 60123456789
  5. 016 789 0123

Should not match:

  1. 07-123 4567 (landline)
  2. 03-1234 5678 (landline)
  3. 012-345 678 (one digit short)
  4. 0223456789 (not 01)
  5. 012-345 67890 (one digit too many)

What it might miss or wrongly catch:

  • 11-digit numbers starting 011 are missed.
  • "+60 12-345 6789" with a space after +60 is missed.
  • It lets any digits follow 012, so 0190000000 matches; it checks the shape, not whether the number exists.
  • Because of ^ and $, a number inside a sentence will not match; to pull a number out of a sentence, remove ^ and $.

How to use it (Google Sheets):

  1. Say the number is in A2.
  2. In B2 enter: =REGEXMATCH(A2, "^(?:\+?60|0)1\d[- ]?\d{3}[- ]?\d{4}$"), giving TRUE or FALSE.
  3. Drag down.
  4. To pull a number out of a sentence: =REGEXEXTRACT(A2, "(?:\+?60|0)1\d[- ]?\d{3}[- ]?\d{4}").
  5. First paste the fake numbers from the table above into column A; TRUE and FALSE should be what I wrote, and only then use it on other data.

AI tools that suit this

  • ChatGPT Suggested tool Free plan

    The most widely used AI chat, for writing, questions and images

  • Claude Suggested tool Free plan

    Strong at long documents, editing and code

  • Gemini Suggested tool Free plan

    Google's AI; generates and edits images, works with Gmail and Docs

Recommendations only, not sponsored. Check each site for what the free plan includes.

This site is made by FullMark Tech

Want your own website, or your shop spreadsheets automated? FullMark Tech builds business websites and custom Excel tools.

Ask on WhatsApp See FullMark Tech services