ToolGrid — Product & Engineering
Leads product strategy, technical architecture, and implementation of the core platform that powers ToolGrid calculators.
AI Credits in development — stay tuned!AI Credits & Points System: Currently in active development. We're building something powerful — stay tuned for updates!
Loading...
Preparing your workspace
Comprehensive regex reference guide with syntax patterns, character classes, quantifiers, anchors, groups, and flags. Includes interactive examples, common patterns (email, phone, URL), and quick lookup for regex syntax elements.
Note: AI can make mistakes, so please double-check it.
Common questions about this tool
A regex cheat sheet is a quick reference guide for regular expression syntax. Use it to look up character classes (\d, \w), quantifiers (*, +, ?), anchors (^, $), groups, and flags. It's perfect for learning regex or quickly finding the right pattern.
Common patterns include \d for digits, \w for word characters, . for any character, * for zero or more, + for one or more, ^ for start, $ for end. The cheat sheet includes examples for email, phone numbers, URLs, and more.
Use character classes: [a-z] for lowercase letters, [0-9] for digits, [A-Za-z] for any letter. Use \d for digits, \w for word characters, \s for whitespace. The cheat sheet shows all character class options with examples.
Greedy quantifiers (*, +, ?) match as much as possible, while lazy quantifiers (*?, +?, ??) match as little as possible. For example, .* matches the entire string, while .*? matches the shortest possible match.
Common flags include 'i' for case-insensitive, 'g' for global (all matches), 'm' for multiline, 's' for dotall. The cheat sheet explains each flag and shows how to use them in different programming languages and tools.
Verified content & sources
This tool's content and its supporting explanations have been created and reviewed by subject-matter experts. Calculations and logic are based on established research sources.
Scope: interactive tool, explanatory content, and related articles.
ToolGrid — Product & Engineering
Leads product strategy, technical architecture, and implementation of the core platform that powers ToolGrid calculators.
ToolGrid — Research & Content
Conducts research, designs calculation methodologies, and produces explanatory content to ensure accurate, practical, and trustworthy tool outputs.
Based on 2 research sources:
Learn what this tool does, when to use it, and how it fits into your workflow.
The Regex Cheat Sheet tool is an interactive reference and playground for regular expressions. It combines a live regex tester, a curated cheat sheet of common tokens, and quick start templates for everyday patterns like emails, phone numbers, dates, and URLs.
You can type or paste a pattern, choose flags, and immediately see which parts of your test text match. At the same time, a sidebar lists important syntax elements such as character classes, quantifiers, anchors, and grouping constructs, each with a short description and example.
The tool also includes an optional AI explanation feature. When you click "Explain with AI", it sends your pattern and flags to a backend helper and returns a human friendly description of what the regex does.
This tool is suitable for beginners who are learning regex for the first time, as well as experienced developers who want a quick reference and a safe place to test and tweak their patterns before using them in code, search tools, or editors.
Regular expressions are a way to describe patterns in text. They are used in many programming languages and tools to search, validate, and transform strings. A regex pattern is made of symbols that stand for literal characters, character classes, repetition rules, and positions like the start or end of a line. A related operation involves visualizing regex patterns as part of a similar workflow.
While powerful, regex syntax can be hard to remember.
Even experienced developers sometimes forget the exact meaning of tokens such as \\b, \\d, or the difference between * and +.
It is also easy to make a small mistake that makes a pattern invalid or causes it to match too much or too little.
Many people learn regex from static cheat sheets in PDF or web pages. These show the syntax, but they do not let you immediately see the effect of a token on real text, and they do not help you quickly insert tokens into your current pattern. Switching back and forth between a guide and a separate tester slows down learning.
The Regex Cheat Sheet in this project brings these pieces together. On one side you have a full regex input and text area for live testing. On the other side you see categories like "Character Classes", "Quantifiers", "Anchors", and "Groups & Alternation", each listing tokens with their meaning and example. Clicking a token inserts it directly into your pattern at the current cursor position.
A template bar across the top gives ready made patterns for common tasks such as validating emails or phone numbers. Selecting a template loads both the pattern and a sample test text so you can experiment by editing and seeing how matches change. Combined with the AI explanation component, the tool helps you understand not just what a pattern matches, but also why. For adjacent tasks, matching text with patterns addresses a complementary step.
RegExp engine, but the flavor label helps you think about where the pattern will be used and how compatible it is.
RegExp object.
If it fails, an "Invalid regex pattern" message appears, and no matches are shown.
A "Live validation" tag above the input indicates that the system is always keeping an eye on syntax correctness.
., \\d, \\w, \\s, character sets, and negated sets), quantifiers (*, +, ?, and range quantifiers), anchors (^, $, \\b), and groups and alternation.
Each item lists a token, a description in plain English, and a brief example.
The Regex Cheat Sheet is helpful whenever you are writing, learning, or debugging regular expressions.
You can use it to build validation patterns for form fields such as email addresses, phone numbers, or dates by starting from the provided templates and adjusting them to your specific rules. Seeing how the test text changes color as you edit the pattern makes it easy to spot edge cases.
When working on data cleaning or search tasks, you can paste real data into the "Test string" area and refine your pattern until it matches exactly the parts you care about. This is safer than editing patterns directly in production scripts without a visual aid.
For learning and teaching, you can walk through the cheat sheet entries with a student or team member.
Click tokens like \\d, \\w, or \\b to drop them into the pattern and then explain the examples shown in the panel and the matches that appear on the right.
When working with related formats, debugging regular expressions can be a useful part of the process.
When you encounter a complex pattern in a codebase that you did not write, you can paste it into the tool and request an AI explanation. The explanation can help you understand the structure before you modify it, reducing the risk of introducing bugs.
Finally, you can use the tool as a quick reference while working in editors, IDEs, or command line tools that support regex. Instead of looking up syntax in multiple sources, you can keep this cheat sheet open, copy tokens or whole patterns, and paste them where needed.
/pattern/flags style.
The tool performs regex execution using JavaScript's built in RegExp engine.
Internally, the performMatches helper receives the pattern, flags, and text, then enforces safe limits before constructing the regex.
It first slices the pattern and text to their maximum lengths and ensures that the g flag is present so that the engine can find all matches, not just the first.
It then loops through the results of regex.exec(), collecting match index, length, text, and captured groups into an array of match objects.
In some workflows, matching phone numbers with regex is a relevant follow-up operation.
To protect against infinite loops caused by patterns that can match empty strings, the function tracks the last index used by the regex.
If a new match does not advance the lastIndex, it manually increments the index by one.
This prevents the engine from repeatedly matching the same position forever.
A cap on the number of stored matches ensures that the match list remains manageable. If any error occurs while building or running the regex, the function returns an empty array rather than throwing, and the UI displays either zero matches or an "Invalid regex" message depending on the validation result.
Pattern validation is handled separately by the isValidRegex helper, which tries to construct a new RegExp with the given pattern and flags.
If this throws, it returns false, which the UI uses to show an error and avoid running performMatches.
The AI explanation feature is implemented in explainRegexWithAI.
It calls an external geminiService.executeGemini helper with the tool identifier "regex-cheat-sheet" and a payload containing the pattern and flags.
If the backend returns a successful response with a string result, that string is shown as the AI explanation; otherwise, a simple fallback message is used.
For related processing needs, matching IP addresses with regex handles a complementary task.
When writing patterns, start small and add complexity step by step. Use the live match highlighting to confirm that each change does what you expect, and avoid building huge patterns all at once.
Keep patterns within the provided length limits. Extremely long patterns are not only harder to understand but can also be slow or unsafe in some engines. If your pattern becomes very large, consider breaking the problem into smaller parts.
Remember that the tool uses JavaScript's regex engine under the hood. Some advanced features from other flavors, such as certain lookbehinds or possessive quantifiers, may not behave exactly as they do in PCRE or Python. Always test critical patterns in the actual environment where you will use them.
Use the cheat sheet as a learning aid, not as a replacement for understanding. Read the descriptions and examples and experiment with them in the test panel so that you internalize the meaning of each token rather than just copying it blindly.
Treat AI explanations as guidance. They can help you reason about complex patterns, but you should still confirm behavior using the live tester and your own understanding. Do not rely solely on AI text for security sensitive or performance critical regex work.
Finally, be mindful of performance when using regex in production systems. Use the tool to spot patterns that may produce many overlapping matches or rely on nested quantifiers that can lead to backtracking issues, and refine them before deploying your code.
We’ll add articles and guides here soon. Check back for tips and best practices.
Summary: Comprehensive regex reference guide with syntax patterns, character classes, quantifiers, anchors, groups, and flags. Includes interactive examples, common patterns (email, phone, URL), and quick lookup for regex syntax elements.