8 puntos por xguru 2020-07-22 | 2 comentarios | Compartir por WhatsApp
  • Biblioteca de JS que permite construir expresiones regulares con funciones compuestas por palabras sencillas en inglés

Ej.) reconocer código hexadecimal de 16 bits

→ /^(?:0x)?([A-Fa-f0-9]{4})$/

→ SE()

  .startOfInput

  .optional.string('0x')

  .capture

    .exactly(4).anyOf

      .range('A', 'F')

      .range('a', 'f')

      .range('0', '9')

    .end()

  .end()

  .endOfInput

  .toRegex();

2 comentarios

 
iolothebard 2020-07-22

No es muy parecido al lenguaje natural...

 
kunggom 2020-07-22

Literalmente, es un DSL.