Code tool

Regex Generator from Samples

Generate a reviewable starting pattern from examples. Broader candidates must match every positive and reject every negative; otherwise use exact escaped alternatives and report conflicts.

In-browser processingNo account requiredPrivacy details ↗

At least one positive. Up to 100 samples combined, 200 characters each and 20,000 input characters total. Empty lines are ignored; other spaces are preserved. Length limits count UTF-16 code units.

Deterministic finite rules, not machine learning. A sample-derived regex is a starting point, not proof of correctness or a ReDoS certification. Anchors control whole-input versus substring matching using JavaScript semantics.

A QUICK WALKTHROUGH

How to use this tool

  1. Enter positive and optional negative samples, one per line.
  2. Choose anchoring and case sensitivity, then generate.
  3. Review the rule, missed positives and matched negatives; try an unseen live sample.

Limited rule inference

Candidates include email, IPv4, ISO date, hex and HTTP/HTTPS URL shapes, shared prefix/suffix, ASCII class lengths and escaped literals. Shapes do not validate real dates, IP ranges or external resources.

Limits and matching

Up to 100 samples combined, 200 characters each and 20,000 input characters. Live samples are limited to 1,000 characters and regex output to 20,000. Empty lines are ignored. No user-supplied regex, eval or uploaded data is used.

GOOD TO KNOW

Common questions

Can this infer any language?

No. It chooses among finite deterministic rules; unfamiliar formats use literal alternatives.

Does rejecting negative samples prove correctness?

No. Unseen values may behave differently. Case-insensitive or unanchored matching can also create conflicts.

Is this a ReDoS audit?

No. Generated patterns use escaped literals or bounded, non-nested classes and quantifiers, but this is not a security certification.