Regular Expression Errors
Catastrophic backtracking, back references, escaping and engine differences.
Understanding Regex errors
Regex problems come in two flavours: it does not match what you expect (usually escaping, greediness, or an engine feature difference) and it matches but takes forever. The second is catastrophic backtracking, a genuine denial-of-service vector known as ReDoS, caused by nested quantifiers over overlapping character classes, such as (a+)+b. Any regex applied to untrusted input should be checked for it.
How to debug Regex errors
- Test against a visualiser that shows backtracking steps, and always test with input that fails to match. That is where catastrophic backtracking appears, not on successful matches.
- Eliminate nested quantifiers over overlapping classes. Rewrite
(a+)+asa+, and prefer possessive quantifiers or atomic groups where the engine supports them. - Know your engine: lookbehind, named groups and Unicode property escapes differ between PCRE, RE2, JavaScript, Python and Go. RE2 (used by Go) deliberately has no backtracking and rejects some patterns outright.
- Anchor patterns with
^and$where you mean a whole-string match. Unanchored patterns silently match substrings. - Set a timeout or use a linear-time engine for user-supplied patterns. Never run an untrusted regex on a request thread.
Tools worth reaching for
regex101.comre2 / RE2JPython re.DEBUGgrep -P for PCRE testingrecheck / redos linters
All 17 Regex errors
- Go: error parsing regexp: invalid or unsupported Perl syntax: (?! NewGo uses RE2, which has no backtracking and therefore no lookahead, no lookbehind and no backreferences. That is a…
- grep: Invalid range end NewA bracket expression contains a range whose end sorts before its start. In POSIX brackets a backslash is literal, so…
- Java: PatternSyntaxException: Dangling meta character '*' near index 0 NewA quantifier such as *, + or ? appeared with nothing before it to repeat. It almost never comes from a regex you meant…
- Java: PatternSyntaxException: Illegal repetition NewA brace appears where the engine expects a quantifier, so a literal { in the pattern is read as the start of {n,m} and…
- JavaScript: Invalid regular expression: Duplicate capture group name NewReusing a named group in different alternatives, as in (?\d{4})-\d{2}|\d{2}/(?\d{4}), only became legal in ES2025…
- Pattern attribute value [a-z-_]+ is not a valid regular expression NewBrowsers now compile the HTML pattern attribute with the v (unicodeSets) flag, which is stricter about character…
- Python: re.error: bad escape \d at position 0 NewThe replacement argument of re.sub is not a pattern. It understands only group references such as \1 and \g plus the…
- Python: re.error: global flags not at the start of the expression NewAn inline flag such as (?i) or (?s) appears somewhere other than the very start of the pattern. Python 3.6 to 3.10…
- Python: re.error: look-behind requires fixed-width pattern NewThe standard re module only implements lookbehind when every alternative is the same known length, so a quantifier or…
- Regex: Catastrophic backtracking (ReDoS)A regular expression takes exponential time on certain inputs due to nested quantifiers or overlapping alternations…
- Regex: Invalid back referenceThe regex references a capture group that doesn't exist (e.g., \3 when there are only 2 groups).
- Regex: Invalid regular expression - unexpected characterA special regex metacharacter (. * + ? | ^ $ [ ] { } ( ) \) was used without escaping, causing a syntax error.
- Regex: Lookbehind not supportedLookbehind support is a property of the engine, not of the pattern: Go RE2 has none at all, Python and Java accept…
- Regex: nothing to repeat at position 0 NewA quantifier appeared with nothing before it to repeat, so the pattern is invalid rather than merely wrong. It is…
- Regex: test() returns false every other call with the /g flag NewA regex with the g or y flag keeps lastIndex between calls, so test() resumes from where the previous match ended and…
- Regex: unbalanced parenthesis / missing closing bracket NewThe pattern has an unmatched grouping construct. In dynamically built patterns this is nearly always user input…
- sed: -e expression #1, char 15: unknown option to `s' Newsed ended the s command early because the pattern or replacement contained the delimiter, nearly always a / inside a…
Other categories
- AI 35Rate limits, context windows, GPU memory and model-serving failures.
- Ansible 18Unreachable hosts, become passwords, undefined variables and Jinja2 failures.
- API 20Auth headers, payload limits, versioning, idempotency and webhook signatures.
- Apple 20Command line tools, dyld, Homebrew permissions, notarisation and Keychain.
- Auth 20OIDC, SAML, Auth0, Okta, Keycloak, passkeys and MFA failures.
- BigData 17Spark, Kafka, Airflow, Snowflake, Flink and Databricks failures.
- C# 18NuGet restore, null references, EF Core migrations, async deadlocks and Blazor…
- C++ 20Segfaults, linker errors, memory corruption and template deduction failures.
- Caching 20Cache stampedes, stale content, Varnish and CloudFront failures.
- CI/CD 18GitHub Actions, GitLab CI, Jenkins, CircleCI: permissions, runners and…
- Client 21CORS, mixed content, module resolution, memory limits and framework runtime…
- Cloud 25IAM permissions, quotas, service limits and credential failures.
- Dart 20Null safety, pub version solving and build toolchain problems.
- Database 41Connections, deadlocks, constraints, replication and memory limits.
- DNS 20NXDOMAIN, SERVFAIL, timeouts, propagation and delegation problems.
- Docker 27Daemon connectivity, disk space, image pulls, ports and architecture mismatches.
- Elixir 18GenServer timeouts, supervision failures and Mix compilation problems.
- Email 20Delivery failures, relay denial, authentication, SPF, DKIM and DMARC.
- Frontend 23Hydration mismatches, bundler resolution, layout shift and font loading.
- Git 20Merge conflicts, rejected pushes, detached HEAD, LFS and repository corruption.
- Go 19Nil map assignment, concurrent map access, context cancellation and deadlocks.
- GraphQL 19Validation, depth limits, N+1 queries and fragment problems.
- gRPC 17Status codes, deadlines, message limits, TLS and HTTP/2 transport failures.
- HTTP 494xx client errors, 5xx server errors, redirects, headers and protocol problems.
- ICMP 23Destination unreachable, time exceeded, fragmentation needed and redirects.
- Ingress 20404 default backend, missing TLS secrets, IngressClass and path matching.
- Java 19Class loading, dependency resolution, connection pools and JVM version…
- JavaScript 42npm resolution, async pitfalls, hydration, memory limits and runtime type…
- Kubernetes 34CrashLoopBackOff, ImagePullBackOff, OOMKilled, RBAC, scheduling and storage.
- Logging 18Log4j, Logback, Fluentd, Logstash and CloudWatch ingestion problems.
- MessageQueue 20Kafka, RabbitMQ, SQS, NATS and Celery: lag, rebalancing and poison messages.
- Mobile 20Gradle, CocoaPods, Xcode signing, Metro bundler and toolchain mismatches.
- Monitoring 18Prometheus scrapes, Grafana data sources, OpenTelemetry exporters and agent…
- Network 35Refused connections, timeouts, resets, MTU problems and port exhaustion.
- Performance 19GC pauses, thread pool starvation and event loop blocking.
- PHP 20Memory limits, execution timeouts, autoloading, Composer and PDO connections.
- Proxy 20nginx, Envoy, HAProxy, Traefik, Caddy and Cloudflare upstream failures.
- Python 35Imports, virtual environments, encoding, concurrency and dependency conflicts.
- Ruby 20Bundler, migrations, native extensions, encoding and asset compilation.
- Rust 19Borrow checker, ownership moves, trait bounds and lifetime mismatches.
- Scala 17Dependency resolution, binary compatibility and type inference failures.
- Security 25JWT validation, CSRF, OAuth grants, SELinux, SSH host keys and CSP.
- Serverless 20Lambda timeouts, package size limits, VPC networking and cold starts.
- Shell 19Command not found, permissions, quoting, expansion and Makefile syntax.
- Storage 19S3 permissions, NFS mounts, quotas, signed URLs and volume attachment.
- Svelte 20Store subscriptions, load functions and server/client boundaries.
- System 26Disk space, systemd units, file descriptors, OOM killer and scheduled jobs.
- Terraform 18State locks, provider auth, drift, dependency cycles and plan-time unknowns.
- Testing 18Jest, pytest, JUnit, Cypress and Playwright: fixtures, snapshots and timeouts.
- TLS 24Untrusted authorities, expiry, hostname mismatch, chains and cipher negotiation.
- TypeScript 19Assignability, missing declarations, strict null checks and generic constraints.
- Virtualization 20VirtualBox, VMware, Hyper-V, WSL, KVM and hypervisor conflicts.
- Web3 17Gas estimation, nonce management and reverted transactions.
- WebAssembly 17Compile errors, memory bounds and host binding mismatches.
- WebServer 20nginx, Apache, IIS and Caddy: binding, permissions, rewrites and TLS.
- Windows 20Installer failures, missing runtimes, update errors and permission problems.