IronFuentesEspañol
P09 · 14 rules · 13 package cases

Regex builder from examples

Give matching and non-matching examples and it returns the regular expression, explained.

Verified calculationThe result depends only on your data and on formulas covered by the tests.

The interface is in English, but what the engine writes is not: rule messages, error messages, audit-log entries and the catalogue of nodes and patterns come from the specification packages, which are written in Spanish and are the source of truth. Their codes are always visible.

Write examples that should match and examples that should not, and it returns an expression that accepts all of the first and rejects all of the second. If it cannot generalise, it hands you the literal version, which always works.

Your examples

One per line.

How it should match
The expressiongeneralised

^(?:FAC\-202[0-9]\-[0-9][0-9][0-9][0-9])$

ecmascript · 3 accepted and 4 rejected, all checked

Probada contra los 3 ejemplos aceptados y los 4 rechazados que diste, y contra nada más. Que funcione con esos no demuestra que funcione con los que no escribiste: si te importa un caso, añádelo como ejemplo y vuelve a generar.

What it says, piece by piece

  • ^empieza aquí: nada puede sobrar por delante
  • (?:abre un grupo que no se captura
  • Fel carácter «F»
  • Ael carácter «A»
  • Cel carácter «C»
  • \-ese carácter tal cual, sin significado especial
  • 2el carácter «2»
  • 0el carácter «0»
  • 2el carácter «2»
  • [0-9]un dígito
  • \-ese carácter tal cual, sin significado especial
  • [0-9]un dígito
  • [0-9]un dígito
  • [0-9]un dígito
  • [0-9]un dígito
  • )cierra el grupo
  • $termina aquí: nada puede sobrar por detrás

The candidates that were tried

Fitness = 1000 × failures + complexity. The lowest among those that do not fail wins.

Each candidate expression with its origin, how many examples it fails and its fitness.
CandidateFailsComplexityFitness
FAC\-2023\-1199|FAC\-2024\-0001|FAC\-2024\-0842Los ejemplos tal cual, escapados y unidos.04343
FAC\-202[0-9]\-[0-9][0-9][0-9][0-9]Todos miden 13; cada posición admite lo que se vio en ella.chosen01313
FAC\-202[\-0123489]{6}Todos empiezan por «FAC-202», y el centro varía.01919
FAC\-[0-9]{4}\-[0-9]{4}Todos se parten en 3 trozos por «-»; cada trozo se generaliza aparte.01313
Literal alternative

^(?:FAC\-2023\-1199|FAC\-2024\-0001|FAC\-2024\-0842)$

Always available. It is longer and covers no new cases, but it cannot get the ones you already have wrong.

Audit log

4 decisions
  1. P09-R-003

    Alternación exacta: acepta los positivos por construcción.

  2. P09-R-004

    Generalizaciones probadas: clase única, clase por posición, prefijo con sufijo y partición por delimitador.

  3. P09-R-009

    Menor aptitud entre los 4 candidato(s) sin fallos; a igual aptitud, el que menos generaliza.

  4. P09-R-013

    No se afirma cobertura sobre casos que no se aportaron.

engine 1.0.0 · package 06cc40e2f262351d…