Write Regex With ChatGPT From Plain English (And Actually Trust It)
promptcore
0:00 / 0:00
Write Regex With ChatGPT From Plain English (And Actually Trust It)
4 просмотра · 3 дн. назад
promptcore
5 подписчиков
4 просмотра · 3 дн. назад
It looks right. It matches your example. And then it breaks on real data, because the regex ChatGPT wrote answered a vaguer question than the one in your head.
Five copy-paste prompt moves to write regular expressions from plain English with AI, and actually trust them: describe the pattern with examples that should and shouldn't match, ask for an explanation piece by piece, test the edge cases yourself, ask for a simpler version, and name your regex flavor (JavaScript vs Python). Works in ChatGPT, Claude, or Gemini.
#Regex #ChatGPT #RegularExpressions
What you will learn:
1. DESCRIBE IT WITH EXAMPLES: the rule in plain English, plus 3-5 strings that should match and 3-5 near misses that shouldn't; ask it to match the whole string
2. ASK FOR THE WHY, PIECE BY PIECE: one line per piece (anchors, character classes, counts), so you can check each part against your rule
3. TEST THE EDGE CASES YOURSELF: run your yes and no lists in a regex tester or a few lines of code, then empty text, extra spaces, and a match hiding inside a longer string
4. ASK FOR A SIMPLER VERSION: same behavior, fewer groups and lookaheads, or a plain string check if that is clearer
5. NAME YOUR FLAVOR: JavaScript and Python differ in details like named-group syntax, what the dollar sign matches near a final newline (use fullmatch in Python), and which digits \d matches
Chapters:
0:00 Intro: looks right, breaks later
0:20 The trap: one vague example
0:41 Why it happens
1:00 The fix: five moves
1:17 1 · Describe it with examples
1:35 Vague ask vs yes / no lists
1:58 Template A · examples, yes and no
2:14 2 · Ask for the why, piece by piece
2:33 A regex, broken down
2:52 Template B · explain every piece
3:10 3 · Test the edge cases yourself
3:32 What actually matched
3:52 Template C · edge-case test
4:12 4 · Ask for a simpler version
4:33 Long pattern vs simple pattern
4:50 Template D · simplify
5:08 5 · Name your flavor
5:28 JavaScript vs Python regex
6:01 Template E · flavor
6:19 Which move, when
6:42 Honest catch: a match isn't proof
7:08 Recap
7:26 Your move
Copy-paste A) Examples, yes and no
WRITE a regex that matches: [the rule in plain English].
SHOULD MATCH: [3-5 real examples].
SHOULD NOT MATCH: [3-5 near misses].
MATCH the whole string, not just part of it.
Copy-paste B) Explain every piece
EXPLAIN this regex piece by piece, one line per piece.
FOR each piece, say what it matches, in plain English.
POINT OUT anything that doesn't fit my rule: [rule].
LIST two strings it would wrongly match, if any.
Copy-paste C) Test the edges
TEST this regex against my lists plus these edge cases: [list].
INCLUDE empty text, extra spaces, and a match inside a longer string.
SHOW a table: input, expected, predicted.
I'LL RUN it myself. Fix only what fails.
Copy-paste D) Ask for simpler
MAKE this regex as simple as possible. Same behavior.
IT MUST still pass every case on my lists.
IF a plain string check is clearer, show that instead.
EXPLAIN what you removed, and why it was safe.
Copy-paste E) Name your flavor
THIS regex runs in [JavaScript / Python / your tool].
WRITE it for that flavor, with the exact flags I need.
IF I move it to [another flavor], list what changes.
GIVE me a tiny test I can run there.
How this differs from our other videos:
Let AI write Excel formulas (and catch its mistakes): that one is spreadsheet formulas. Here it's text patterns you use in code, editors, and search tools.
Write SQL queries in plain English: that one asks a database a question. Here you describe the shape of text you want to match or reject.
Unit tests that actually catch bugs: that one tests whole functions. Here you test one pattern against yes and no lists.
Honest catch: Even with these moves, AI can hand you a pattern that looks right and still misses a case you never listed. Nested repeats can get very slow on long input. Test it in your own project before you ship it. Use made-up samples, not private customer data, and check your team's AI rules.
Made-up demos: the order-code format (two capital letters, a dash, four digits), the codes, the patterns, the test results and the assistant reply shown in the video are illustrative examples written for this video, not real data or real AI output.
Accuracy note: these are prompt habits, not features of any AI product. JavaScript and Python are examples; other tools (Java, databases, code editors) have their own regex flavors. Flavor notes refer to JavaScript RegExp and Python's built-in re module. Bracketed parts are placeholders.
Like and subscribe for more practical AI workflows.
#Regex #ChatGPT #RegularExpressions #RegexTutorial #LearnRegex #RegexForBeginners #RegexPatterns #PatternMatching #StringMatching #JavaScript #Python #JavaScriptRegex #PythonRegex #EdgeCases #AICoding #CodingWithAI #AIForDevelopers #ChatGPTForDevelopers #ChatGPTPrompts #Claude #Gemini #PromptEngineering #CopyPastePrompts #Programming #promptcore #AIproductivity