JavaScript Regex Cheatsheet - Online Interactive Pattern Reference
Interactive cheatsheet for JavaScript regular expressions with live examples. Click any token to see its explanation and test it on sample text immediately.
UD5 Toolkit
Test, learn & copy regular expressions — live matching, searchable reference, and practical examples
., *, +, [], ()) to create flexible and powerful search patterns. Regex is supported in virtually all programming languages including JavaScript, Python, Java, PHP, and .NET.
*, +, ?, {n,m}) match as many characters as possible while still allowing the overall pattern to succeed. Lazy quantifiers (*?, +?, ??, {n,m}?) match as few characters as possible. For example, given the string "<div>hello</div>", the greedy pattern <.*> matches the entire string, while the lazy pattern <.*?> matches just "<div>".
\. Common metacharacters that need escaping include: ., *, +, ?, ^, $, {, }, (, ), [, ], |, /, and \. For example, to match a literal period, use \.. Inside a character class [], most metacharacters lose their special meaning and don't need escaping.
(?=…) and lookbehind (?<=…) are zero-width assertions that check if a pattern exists (or doesn't exist) ahead of or behind the current position, without consuming characters. Positive lookahead (?=pattern) asserts the pattern does follow. Negative lookahead (?!pattern) asserts it does not follow. Similarly, positive lookbehind (?<=pattern) checks behind, and negative lookbehind (? checks that a pattern does not precede. These are invaluable for complex validation without including the assertion in the match.
match() return an array of all matches, and matchAll() returns an iterator over all match details including capture groups. In JavaScript, the 'g' flag also affects the behavior of exec() by maintaining a lastIndex for iterative matching.
(pattern) store the matched content in memory, accessible via backreferences (\1, \2) or in results arrays. Non-capturing groups (?:pattern) group patterns for logical or repetition purposes without storing the match. Non-capturing groups are more memory-efficient and should be preferred when you don't need to reference the matched content later. They also keep result arrays cleaner by not adding unnecessary capture entries.
^ and $ match line starts/ends), s (dotall — . matches newline characters), u (unicode — enables full Unicode support), and y (sticky — matches only from lastIndex position). Flags vary slightly across programming languages and regex engines.
Interactive cheatsheet for JavaScript regular expressions with live examples. Click any token to see its explanation and test it on sample text immediately.
Search and copy HTML entities for arrows, math, currency, and symbols. See the glyph and code. Fast reference.
Enter a CSS selector and see its specificity broken down into A,B,C columns with a visual weight comparison. Learn specificity.
Recreate the target CSS linear gradient by adjusting stops and colors. A unique game for front‑end developers to master gradients.
Create and format Markdown tables by adjusting rows and columns. Align text, copy the raw Markdown. Perfect for README files.
Drop a PDF and extract any embedded JavaScript or form actions. Check for malicious code. Privacy‑friendly analysis.
Enter a common chemical name to see summary hazard pictograms and precautions. Quick reference.
Search for common ingredient substitutions (e.g., buttermilk, egg, cornstarch). Quick reference for when you're missing something. Local data.
Choose Babel presets (env, React, TypeScript) and plugins. Get a clean babel.config.json to transpile your code. Local tool.
Quick reference of HTTP methods with their semantics, idempotency, and example REST usage. Static, fast.
Create beautiful, syntax-highlighted screenshots of your code snippets. Choose themes and export as PNG. All client-side canvas rendering.
Select text and see the Selection object properties. Create ranges programmatically. Understand how rich‑text editors work.
Drag and drop pieces to set up a chess position. Generate FEN string and copy to share. Analyze openings. Local only.
Generate the doGet() and doPost() boilerplate for a Google Apps Script web app. Ready to paste into the editor.
Create a looping animated gradient background with multiple color stops. Copy the complete CSS keyframes. Eye‑catching.
See how `animation‑composition: replace, add, accumulate` works by layering animations on the same property. Understand the spec.
Limit browser gestures on an element: pan‑x, pinch‑zoom, manipulation. Draw on a canvas to test. Mobile dev helper.
Chain multiple CSS filter functions and see the result on an image. Copy the filter string. No upload.
Enter a resource name and HTTP method to get a complete Express route handler with try/catch and comments.
Automatically remove the background from any photo using a small on‑device AI model (WASM). No upload. Works offline.
Generate an SVG placeholder image with custom text, width, height, and colors. Use as a placeholder service. Pure SVG.
Answer questions about project type and strength needed to get a joint recommendation. Animations.
Fill in a component name and generate a complete Stencil.js component with TSX, CSS, and test files. Quick start.
Apply real-time CSS filters or canvas effects to a video and download the processed output. Experiment with video post-processing locally.
Generate a random Sudoku puzzle with a unique solution. Choose difficulty and type numbers on the board. Timer and mistake counter.
Select a color in an image and completely remove it or make it transparent. Great for background removal experiments. Local.
Mix two or more colors using subtractive (CMYK‑like) blending. See what happens when you combine real paints. Brush effect canvas.
Apply a blur effect to image background while keeping the subject sharp. Simple brush selection for area to keep sharp. CSS+Canvas implementation, local only.
Keep one selected color and turn the rest of the image to grayscale. Eye‑catching selective color effect. Pure canvas.
Shift the pitch of any audio clip by semitones without affecting playback speed. Perfect for music transposition. Local Web Audio.