Validation25 patterns
Email Address Validation
Match and validate email addresses in the standard user@domain.tld format.
/[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a…/gUS Phone Number
Match US phone numbers in common formats: (555) 867-5309, 555-867-5309, 5558675309.
/\(?\d{3}\)?[\s.\-]?\d{3}[\s.\-]?\d{4}/gCredit Card Number
Match 16-digit credit card numbers with optional spaces or hyphens between groups of 4.
/\b(?:\d{4}[\s\-]?){3}\d{4}\b/gUS ZIP Code
Match US ZIP codes in 5-digit (12345) and ZIP+4 (12345-6789) formats.
/\b\d{5}(?:[\-\s]\d{4})?\b/gUS Social Security Number
Match US Social Security Numbers in the canonical XXX-XX-XXXX format.
/\b\d{3}-\d{2}-\d{4}\b/gCanadian Postal Code
Match Canadian postal codes in the A1A 1A1 or A1A1A1 format with valid first-letter prefixes.
/[ABCEGHJ-NPRSTVXY]\d[A-Z] ?\d[A-Z]\d/giUK Postcode
Match UK postcodes in the common outward + inward format (e.g. SW1A 1AA, EC1V 9LB).
/[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}/giISBN-10
Match 10-digit ISBNs, allowing optional hyphens or spaces between groups.
/\b(?:\d[\- ]?){9}[\dXx]\b/gISBN-13
Match 13-digit ISBNs starting with 978 or 979, with optional hyphens or spaces.
/\b97[89][\- ]?(?:\d[\- ]?){9}\d\b/gUsername
Validate usernames that are 3–16 characters long and contain only letters, digits, underscores, and hyphens.
/^[a-zA-Z0-9_\-]{3,16}$/International Phone (E.164)
Validate phone numbers in ITU-T E.164 international format: a + sign followed by 2–15 digits, first digit non-zero.
/^\+[1-9]\d{1,14}$/Twitter / X Handle
Match Twitter/X @handles — 1 to 15 characters of letters, digits, or underscores preceded by @.
/@([A-Za-z0-9_]{1,15})\b/gCron Expression
Validate standard 5-field Unix cron expressions: minute, hour, day-of-month, month, day-of-week.
/^(\*|([0-5]?\d))\s+(\*|([01]?\d|2[0-3]…/Alphanumeric Only
Match strings containing only letters (A–Z, a–z) and digits (0–9), with no spaces or special characters.
/^[a-zA-Z0-9]+$/International Phone Number (Loose)
Match international phone numbers in a variety of loose formats including country codes, area codes, and separators.
/\+?[1-9]\d{0,3}[\s.\-]?(?:\(?\d{1,4}\)…/gMIME Type
Validate MIME media type strings like text/html, application/json, or image/png; charset=utf-8.
/^([a-z]+)\/([a-z0-9][a-z0-9!#$&\-^_.]*…/iIBAN (International Bank Account Number)
Validate IBAN bank account identifiers: 2-letter country code, 2 check digits, 11–30 alphanumerics.
/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/SWIFT / BIC Code
Validate SWIFT/BIC bank identifier codes — 8 chars (head office) or 11 chars (branch).
/^[A-Z]{6}[A-Z0-9]{2}(?:[A-Z0-9]{3})?$/Email Local Part (Before @)
Validate just the local part of an email address (the bit before the @).
/^[a-zA-Z0-9._%+\-]{1,64}$/Password (No Special Chars)
Validate passwords requiring at least one lowercase, one uppercase, one digit, and minimum 8 characters — no special characters required.
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z…/ISO 4217 Currency Code
Validate 3-letter ISO 4217 currency codes (USD, EUR, GBP, JPY, etc.) — structural check only.
/^[A-Z]{3}$/ISO 3166-1 alpha-2 Country Code
Validate 2-letter ISO 3166-1 alpha-2 country codes (US, GB, FR, JP, etc.) — structural check only.
/^[A-Z]{2}$/Email Domain Part (After @)
Validate just the domain portion of an email address — the bit after the @.
/^[a-zA-Z0-9](?:[a-zA-Z0-9.\-]{0,253}[a…/Cron Expression (Quartz/Spring, 6-Field)
Validate 6-field Quartz/Spring cron expressions including the seconds field at the front.
/^(\*|([0-5]?\d))\s+(\*|([0-5]?\d))\s+(…/BCP 47 Language Tag
Validate BCP 47 language tags like `en`, `en-US`, `zh-Hant-TW`, or `pt-BR`.
/^[a-zA-Z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/Web25 patterns
URL Validation
Match http and https URLs with optional www prefix, paths, query strings, and fragments.
/https?:\/\/(?:www\.)?[\w\-]+(?:\.[\w\-…/giHex Color Code
Match CSS hex color codes in both 3-digit (#RGB) and 6-digit (#RRGGBB) formats.
/#(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/gURL Slug
Validate URL slugs: lowercase letters and digits separated by single hyphens, no leading/trailing hyphens.
/^[a-z0-9]+(?:-[a-z0-9]+)*$/HTML Tag Matcher
Match paired HTML tags and capture the tag name and inner content using a back-reference.
/<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>([\s\S]…/gHTML Comment
Match HTML comments, including multi-line comments and empty ones.
/<!--[\s\S]*?-->/gCSS rgb() Color
Match CSS rgb() and rgba() color functions, including an optional alpha channel.
/rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*…/giHTML Attribute
Match HTML attributes of the form name="value" or name='value' and capture both parts.
/\b([a-zA-Z][a-zA-Z0-9\-]*)=["']([^"']*…/gData URI
Match base64-encoded data URIs, including the MIME type and the base64 payload.
/data:[\w\/+\-.]+(?:;[\w=\-]+)*;base64,…/giYouTube Video ID
Extract 11-character YouTube video IDs from long URLs, short URLs, or embed URLs.
/(?:youtube\.com\/watch\?v=|youtu\.be\/…/gCSS hsl() / hsla() Color
Match CSS hsl() and hsla() color functions, capturing hue (0–360), saturation, lightness, and optional alpha.
/hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s…/giHTML Entity
Match HTML entities in named (`&`), numeric (`{`), or hex (`💩`) form.
/&(?:[a-zA-Z][a-zA-Z0-9]+|#\d+|#x[0-9a-…/gCSS Class from `class=""` Attribute
Extract the value of a `class="..."` attribute from raw HTML, handling double or single quotes.
/class\s*=\s*["']([^"']+)["']/giGitHub Repository URL
Match GitHub repository URLs and capture the owner and repo segments.
/https?:\/\/(?:www\.)?github\.com\/([A-…/gCSS Custom Property (Variable)
Match CSS custom properties (variables) like `--brand-color` or `--font-size-lg`.
/--[a-zA-Z][a-zA-Z0-9\-]*/gSlug (Unicode Letters Allowed)
Validate URL slugs allowing Unicode letters (`café-rénové`), as supported by Next.js i18n routing.
/^[\p{L}\p{N}]+(?:-[\p{L}\p{N}]+)*$/uHTML5 Color Input Value
Validate the value of an HTML5 `<input type="color">` — exactly 6 hex digits with leading hash.
/^#[0-9a-fA-F]{6}$/Twitter / X URL
Match Twitter/X profile and status URLs, capturing the handle and (optional) tweet ID.
/https?:\/\/(?:www\.)?(?:twitter|x)\.co…/gLinkedIn Profile URL
Match LinkedIn profile URLs and capture the profile slug.
/https?:\/\/(?:www\.)?linkedin\.com\/in…/gURL Query String
Extract the query string portion of a URL (everything between `?` and `#` or end-of-string).
/\?([^#\s]+)/gHTTP Content-Type Header
Parse the value of an HTTP Content-Type header, capturing the media type and optional charset.
/Content-Type:\s*([a-z]+\/[\w.+\-]+)(?:…/giURL Path Segment
Match individual `/segment` parts of a URL path, capturing each one.
/\/([^\/?#\s]+)/gXML Namespace Declaration
Match XML namespace declarations (`xmlns="..."` and `xmlns:prefix="..."`), capturing the prefix and URI.
/xmlns(?::([\w\-]+))?\s*=\s*["']([^"']+…/gOpenAPI Path Template
Match OpenAPI / Express-style path templates with `{param}` (or `:param` after substitution) placeholders.
/\/[\w\-]+(?:\/(?:\{[\w\-]+\}|[\w\-]+))…/gCookie Header Value
Parse name=value pairs from an HTTP `Cookie:` header value.
/([^=;\s]+)=([^;]+)/gXML Processing Instruction
Match XML processing instructions like `<?xml version="1.0" encoding="utf-8"?>` or `<?xml-stylesheet href="..."?>`.
/<\?[\w\-]+(?:\s+[\w\-]+\s*=\s*["'][^"'…/gNetworking15 patterns
IPv4 Address
Match valid IPv4 addresses with each octet constrained to 0–255.
/(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){…/gIPv6 Address
Match full (non-compressed) IPv6 addresses written as eight colon-separated hextets.
/(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,…/gMAC Address
Match 48-bit MAC addresses written with colon or hyphen separators (e.g. 00:1A:2B:3C:4D:5E).
/(?:[0-9A-Fa-f]{2}[:\-]){5}[0-9A-Fa-f]{…/gTCP/UDP Port Number
Match port numbers (1–65535) following a colon, as you'd find in host:port strings.
/:(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[…/gDomain Name
Match fully-qualified domain names like example.com or api.sub.example.co.uk.
/(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a…/gHTTP Status Code
Match 3-digit HTTP status codes in the 1xx–5xx range.
/\b[1-5]\d{2}\b/gIP Address with CIDR Notation
Match IPv4 addresses with CIDR prefix notation such as 10.0.0.0/8 or 192.168.1.0/24.
/(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){…/gPrivate IP Address (RFC 1918)
Match IPv4 addresses in the RFC 1918 private ranges: 10/8, 192.168/16, and 172.16/12.
/\b(?:10(?:\.\d{1,3}){3}|192\.168(?:\.\…/gHostname (Single Label, RFC 1123)
Validate a single-label hostname per RFC 1123: 1–63 chars, letters/digits/hyphens, can't start or end with hyphen.
/^[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-z…/MongoDB Connection URI
Match MongoDB connection URIs in both standard `mongodb://` and SRV `mongodb+srv://` formats.
/mongodb(?:\+srv)?:\/\/(?:[^:@\s]+(?::[…/gGeneric Connection String (URL Form)
Parse generic URL-form connection strings: `protocol://[user[:pass]@]host[:port][/database]`.
/([a-zA-Z][\w+\-.]*):\/\/(?:([^:@\s]+)(…/gRedis Connection URL
Match Redis connection URLs in both `redis://` and `rediss://` (TLS) forms, capturing user, password, host, port, and DB index.
/rediss?:\/\/(?:([^:@\s]+)(?::([^@\s]*)…/gPostgreSQL DSN
Match PostgreSQL DSN connection strings (`postgres://` or `postgresql://`), capturing the standard URL components.
/postgres(?:ql)?:\/\/(?:([^:@\s]+)(?::(…/gFTP URL
Match FTP and FTPS URLs, capturing optional credentials, host, port, and path.
/ftps?:\/\/(?:([^:@\s]+)(?::([^@\s]*))?…/gJDBC Connection URL
Match JDBC connection URLs in the standard `jdbc:driver://host[:port][/database]` form.
/jdbc:[a-z0-9]+:\/\/[^\/?\s]+(?:\/[\w\-…/gDates & Times7 patterns
ISO 8601 Date
Match dates in ISO 8601 format: YYYY-MM-DD with valid month (01–12) and day (01–31) ranges.
/\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]…/gUS Date Format (MM/DD/YYYY)
Match US-style dates in MM/DD/YYYY format with range validation.
/(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[…/gEuropean Date Format (DD/MM/YYYY)
Match European-style dates in DD/MM/YYYY format with valid day (01–31) and month (01–12) ranges.
/(?:0[1-9]|[12]\d|3[01])\/(?:0[1-9]|1[0…/g24-Hour Time
Match 24-hour time formats HH:MM or HH:MM:SS with valid hour (00–23) and minute/second (00–59) ranges.
/(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?/g12-Hour Time with AM/PM
Match 12-hour time formats with AM or PM suffix — e.g. 9:30 AM, 11:45:15 pm.
/(?:0?[1-9]|1[0-2]):[0-5]\d(?::[0-5]\d)…/gUnix Timestamp
Match 10-digit Unix timestamps (seconds since epoch) for dates between 2001 and 2286.
/\b1[0-9]{9}\b/gISO 8601 Date-Time
Match full ISO 8601 date-times with timezone offset or Z suffix (e.g. 2024-01-15T14:30:00Z).
/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:…/gSecurity12 patterns
Strong Password
Enforce strong passwords: min 8 chars, at least one lowercase, uppercase, digit, and special character.
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^…/JWT Token
Match JSON Web Tokens (JWTs) — three base64url-encoded segments separated by dots.
/eyJ[A-Za-z0-9_\-]+\.eyJ[A-Za-z0-9_\-]+…/gGeneric API Key
Match generic long alphanumeric tokens (32+ chars) typical of API keys and access tokens.
/\b[A-Za-z0-9_\-]{32,}\b/gBitcoin Address
Match Bitcoin addresses in legacy (P2PKH/P2SH) and SegWit Bech32 (bc1) formats.
/\b(?:[13][a-km-zA-HJ-NP-Z1-9]{25,34}|b…/gbcrypt Password Hash
Match bcrypt password hashes in their canonical $2a$/$2b$/$2y$ prefixed format.
/\$2[abxy]?\$\d{2}\$[./A-Za-z0-9]{53}/gAWS Access Key ID
Match AWS access key IDs (both long-term AKIA and temporary ASIA prefixes).
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/gBearer Token (Authorization Header)
Match Bearer token values from HTTP Authorization headers, capturing the raw token string.
/Bearer\s+([A-Za-z0-9\-._~+\/]+=*)/iPEM Certificate Block
Match PEM-encoded certificate and key blocks, capturing the block type and base64 content.
/-----BEGIN ([A-Z ]+)-----([\s\S]+?)---…/gSSH Public Key
Match SSH public keys in OpenSSH `authorized_keys` format, including the optional comment field.
/ssh-(?:rsa|dss|ed25519|ecdsa-sha2-nist…/gStripe API Key
Match Stripe API keys: secret (sk_), publishable (pk_), or restricted (rk_), in test or live mode.
/(?:sk|pk|rk)_(?:test|live)_[A-Za-z0-9]…/gGitHub Personal Access Token
Match GitHub Personal Access Tokens (classic + fine-grained) and OAuth tokens by their `ghX_` prefix.
/gh[pousr]_[A-Za-z0-9]{36,255}/gPEM Private Key Block
Match PEM-encoded private key blocks across the common variants (RSA, EC, DSA, OpenSSH, encrypted, PGP).
/-----BEGIN (?:RSA |EC |DSA |OPENSSH |E…/gIdentifiers15 patterns
UUID (v1–v5)
Match RFC 4122 UUIDs (versions 1–5) in the standard 8-4-4-4-12 hex format.
/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{…/giSemantic Version (SemVer)
Match semantic version strings like 1.2.3, 1.2.3-beta.1, or 1.2.3+build.42.
/(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[…/gMongoDB ObjectId
Match MongoDB ObjectId values — 24-character hexadecimal strings.
/\b[0-9a-fA-F]{24}\b/gULID
Match 26-character ULIDs (Universally Unique Lexicographically Sortable Identifiers).
/\b[0-9A-HJKMNP-TV-Z]{26}\b/gGit Commit SHA
Match Git commit hashes, both short (7 chars) and full (40 chars) forms.
/\b[0-9a-f]{7,40}\b/gDocker Image Tag
Match Docker image references with an explicit tag — e.g. nginx:1.21, mycorp/service:v2.3.1.
/\b[a-z0-9]+(?:[._\-\/][a-z0-9]+)*:[\w.…/gSlack User Mention
Match Slack user mentions in their raw form <@U01234ABC> as delivered by the Events API.
/<@U[A-Z0-9]{8,}>/gnpm Package Name
Validate npm package names including scoped packages (@org/package), per the npm naming spec.
/^(?:@[a-z0-9\-*~][a-z0-9\-*._~]*\/)?[a…/Git Remote URL (HTTPS or SSH)
Match git remote URLs in both `git@host:org/repo` and `https://host/org/repo` forms.
/(?:git@|https?:\/\/)([\w.\-]+)[:\/]([\…/AWS ARN (Amazon Resource Name)
Match AWS ARNs (Amazon Resource Names) across commercial, China, and GovCloud partitions.
/arn:(?:aws|aws-cn|aws-us-gov):[a-z0-9\…/gKubernetes Label (key=value)
Validate Kubernetes label `key=value` pairs per the K8s naming spec.
/^([a-zA-Z0-9](?:[\w.\-]{0,61}[a-zA-Z0-…/AWS S3 Bucket Name
Validate AWS S3 bucket names per the standard naming rules: 3–63 chars, lowercase, alphanumeric + dots + hyphens.
/^[a-z0-9](?:[a-z0-9.\-]{1,61}[a-z0-9])…/GitHub Actions Expression
Match `${{ expression }}` interpolations used in GitHub Actions workflow YAML.
/\$\{\{\s*([^}]+?)\s*\}\}/gPython Package Name (PEP 508)
Validate Python distribution package names per PEP 508: letters, digits, dots, underscores, hyphens.
/^[A-Za-z0-9](?:[A-Za-z0-9._\-]*[A-Za-z…/Kubernetes Pod Name (RFC 1123)
Validate Kubernetes pod names per the RFC 1123 DNS label rules — lowercase, ≤63 chars, no leading/trailing hyphen.
/^[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?…/Text Processing38 patterns
Markdown Link
Match Markdown links [link text](url) and capture both the display text and the URL.
/\[([^\]]+)\]\(([^)]+)\)/gMarkdown Heading
Matches markdown ATX-style headings (# through ######).
/^(#{1,6})\s+(.+)$/gmMarkdown Image
Matches Markdown image syntax .
/!\[([^\]]*)\]\(([^)]+)\)/gWhitespace-Only Line
Matches lines containing only whitespace (or empty lines).
/^\s*$/gmDuplicate Word
Detects consecutive duplicate words using a backreference.
/\b(\w+)\s+\1\b/giSentence Boundary
Matches sentence boundaries (punctuation followed by whitespace and a capital letter).
/[.!?]\s+(?=[A-Z])/gHashtag
Match hashtags (# followed by word characters) in social media posts, including accented Latin characters.
/#([\w\u00C0-\u024F]+)/gBase64 String
Match Base64-encoded strings, including proper padding with = and == characters.
/(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/…/gWhitespace Trim (Leading & Trailing)
Match leading and/or trailing whitespace on a string — the regex equivalent of .trim().
/^\s+|\s+$/gUnix Environment Variable Reference
Match Unix shell environment variable references in both $VAR and ${VAR} forms.
/\$\{?([A-Z_][A-Z0-9_]*)\}?/gSemantic Commit Message
Validate Conventional Commits format: type(scope)!: description.
/^(feat|fix|docs|style|refactor|perf|te…/iEmoji (Unicode)
Match emoji characters across the main Unicode emoji ranges — requires the Unicode flag in JavaScript.
/[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\…/guNamed Capture Group (Date)
Demonstrate named capture groups by extracting year/month/day from ISO-style dates.
/(?<year>\d{4})-(?<month>\d{2})-(?<day>…/gPositive Lookahead (Password)
Use positive lookahead `(?=...)` to require the password contain at least one digit and one uppercase letter.
/^(?=.*\d)(?=.*[A-Z])[A-Za-z\d]{8,}$/Negative Lookbehind (Decimals Without $)
Use negative lookbehind `(?<!...)` to match decimal numbers NOT preceded by a dollar sign.
/(?<!\$)\b\d+\.\d{2}\b/gWord Boundary (Whole Word Match)
Match the whole word `cat` without matching it inside other words like `concatenate` or `category`.
/\bcat\b/giNon-Capturing Group (Image URL)
Use non-capturing groups `(?:...)` to alternate without polluting the captured-groups list.
/(?:https?:\/\/)\S+\.(?:jpg|jpeg|png|gi…/giTrailing Whitespace (Per Line)
Match trailing spaces and tabs at the end of each line — the regex linters use to flag dirty whitespace.
/[ \t]+$/gmPython f-String Expression
Match `{expression}` placeholders inside Python f-strings (or any single-brace template syntax).
/\{([^{}]+)\}/gJavaScript Template Literal Placeholder
Match `${expression}` placeholders inside JavaScript template literals.
/\$\{([^{}]+)\}/gTriple-Quoted String (Python / TS)
Match triple-quoted strings (Python docstrings, TypeScript triple-quote, etc.) including newlines.
/"""([\s\S]*?)"""/gLazy / Non-Greedy Quantifier
Demonstrate lazy quantifiers `+?` by matching the SHORTEST HTML-like tag rather than the longest greedy span.
/<.+?>/gJSON Key-Value Pair (Simple)
Extract simple `"key": value` pairs from JSON-ish text (strings, numbers, booleans, null).
/"([^"\\]+)"\s*:\s*("[^"\\]*"|-?\d+(?:\…/gSQL SELECT Statement
Match the column list and table name from a SQL SELECT ... FROM statement.
/SELECT\s+(.+?)\s+FROM\s+([\w."`\[\]]+)/gisPython Import Statement
Match Python `import x` and `from x import y` statements, capturing the module and target.
/^(?:from\s+([\w.]+)\s+)?import\s+([\w.…/mC-Style Block Comment
Match C-style /* ... */ block comments across multiple lines.
/\/\*[\s\S]*?\*\//gSingle-Line Comment (// or #)
Match single-line comments using either the `//` (C-family) or `#` (shell, Python, Ruby, YAML) marker.
/(?://|#).*$/gmKeep-a-Changelog Entry Header
Match Keep-a-Changelog style version headers like `## [1.2.3] - 2024-01-15` or `## 2.0.0`.
/^##\s+\[?([\w.\-]+)\]?(?:\s*-\s*(\d{4}…/gmJSON Number (Strict)
Match JSON-spec numbers — disallows leading zeros (no `01`), allows decimals and exponents.
/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?…/gGraphQL Operation Header
Match GraphQL operation headers — `query`, `mutation`, or `subscription` — capturing the operation name.
/(query|mutation|subscription)\s+(\w+)?…/gJavaScript Variable Declaration
Match JavaScript / TypeScript variable declarations (`var`, `let`, `const`), capturing the keyword and identifier name.
/\b(var|let|const)\s+([a-zA-Z_$][\w$]*)…/gmNegative Lookahead
Use negative lookahead `(?!...)` to match words that are NOT in a blocklist (here: log-level keywords).
/\b(?!error|warn|debug)[a-z]+\b/giTab Character
Match literal tab characters — the regex behind every formatter / linter that yells about indentation.
/\t/gNon-ASCII Character
Match runs of non-ASCII characters (anything outside U+0000–U+007F).
/[^\x00-\x7F]+/gJSON Boolean / Null Literal
Match JSON `true`, `false`, and `null` literal values, with word boundaries to avoid partial matches.
/\b(true|false|null)\b/gTerraform Resource Block Header
Match the opening line of a Terraform `resource "type" "name" {` block, capturing the resource type and local name.
/resource\s+"([\w\-]+)"\s+"([\w\-]+)"\s…/gHCL / Terraform Variable Reference
Match Terraform / HCL references like `var.name`, `local.foo`, `module.x.output`, or `data.aws_ami.ubuntu.id`.
/\b(?:var|local|module|data)\.[a-zA-Z_]…/gJava Package Declaration
Match Java `package com.example.app;` declarations and capture the dotted package path.
/^\s*package\s+([a-z][\w]*(?:\.[a-z][\w…/mNumbers10 patterns
Integer
Matches whole integers, including negative numbers.
/^-?\d+$/Decimal Number
Matches decimal numbers, including integers and negatives.
/^-?\d+(\.\d+)?$/US Currency (USD)
Matches USD currency amounts with optional $ sign, thousands separators, and cents.
/^\$?\d{1,3}(,\d{3})*(\.\d{2})?$/Percentage
Matches percentage values with optional decimal and a trailing % sign.
/^\d+(\.\d+)?%$/Scientific Notation
Matches numbers in scientific/exponential notation (e.g., 1.5e10).
/^-?\d+(\.\d+)?[eE][+-]?\d+$/USD Currency (Inline)
Match US dollar amounts inline in text: `$1,234.56`, `$99`, `$1,000,000.00`.
/\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?/gHexadecimal Number Literal
Match hexadecimal number literals like `0xFF`, `0x1A2B`, or `0XdeadBeef`.
/\b0[xX][0-9a-fA-F]+\b/gBinary Number Literal
Match binary number literals like `0b1010` or `0B11110000`.
/\b0[bB][01]+\b/gFloat / Scientific Number
Match floating-point and scientific-notation numbers including `1.5`, `.25`, `1e10`, `-3.14E-2`.
/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d…/gOctal Number Literal
Match modern ECMAScript-style octal literals (`0o755`) — strict per ES6+ syntax.
/\b0[oO][0-7]+\b/gFile & Path9 patterns
Unix File Path
Matches absolute Unix/Linux file paths.
/^(/[^/\0]+)+/?$/Windows File Path
Matches absolute Windows file paths (e.g., C:\Users\file.txt).
/^[A-Za-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[…/File Extension
Captures the file extension from a filename.
/\.([A-Za-z0-9]+)$/Relative Path
Matches relative file paths (./, ../, or path/to/file).
/^(\.{1,2}\/)?([^\/\0]+\/)*[^\/\0]+$/Hidden File (Dotfile)
Matches Unix-style hidden files (dotfiles) like .gitignore or .env.
/^\.[^.\s/\\][^/\\]*$/Image File Extension
Match common image file extensions: jpg, jpeg, png, gif, webp, svg, avif, bmp, ico, tif, tiff.
/\.(jpe?g|png|gif|webp|svg|avif|bmp|ico…/i.env File Key-Value Line
Parse KEY=value lines from .env config files, handling quoted values and trailing comments.
/^([A-Z_][A-Z0-9_]*)\s*=\s*(?:"([^"]*)"…/mVideo File Extension
Match common video file extensions: mp4, mov, avi, mkv, webm, m4v, flv, wmv, mpg, mpeg.
/\.(mp4|mov|avi|mkv|webm|m4v|flv|wmv|mp…/iDockerfile ENV Instruction
Match Dockerfile `ENV KEY=value` (or `ENV KEY value`) instructions, capturing key and value.
/^ENV\s+([A-Z_][A-Z0-9_]*)(?:[=\s]+)(.+…/gmLogs9 patterns
Apache Common Log Format
Parses Apache Common Log Format entries.
/^(\S+) (\S+) (\S+) \[([^\]]+)\] "(\S+)…/Syslog (RFC 5424)
Parses RFC 5424 syslog messages.
/^<(\d{1,3})>(\d+) (\S+) (\S+) (\S+) (\…/Log Level
Matches standard log level keywords in log lines.
/\b(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\…/gJava Stack Trace Line
Matches a single Java stack trace frame line.
/^\s*at\s+([\w$.]+)\(([^)]+)\)$/gmNginx Error Log
Parses Nginx error log lines.
/^(\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2})…/Logfmt Key-Value Pair
Parse key=value pairs from logfmt-style log lines, supporting both quoted and unquoted values.
/([a-zA-Z_][\w.]*)=("[^"]*"|\S+)/gJSON Log Line (Single-Line Object)
Match a single-line JSON object — typical of structured logging from services like slog, Bunyan, or Pino.
/^\{(?:[^{}]|\{[^{}]*\})*\}$/Log4j Pattern Layout Token
Match Log4j / Logback PatternLayout conversion specifiers like `%d{yyyy-MM-dd}`, `%-5p`, or `%c{1}`.
/%(?:-?\d+)?(?:\.\d+)?[a-zA-Z](?:\{[^}]…/gCloudWatch Log Stream Path
Match AWS CloudWatch log group / stream paths like `/aws/lambda/my-function` or `/aws/ecs/cluster-name`.
/\/aws\/(?:lambda|ecs|eks|apigateway|co…/gTest any regex in your browser
RegexPro's interactive tester highlights matches in real time across JavaScript, Python, and Go — no sign-up, no installs.
Open Regex Tester