Regex es una expresión regular que define o restringe lo que un usuario ingresa / completa en las preguntas de entrada (texto de entrada, entero, decimal, etc.). Tenemos una disposición para usarlo tanto en la lista como en los flujos de trabajo, vea a continuación cómo formular uno.

  1. Definición de caracteres:

  • [] - grupo de caracteres

  •  \ - señala una secuencia especial (puede ser usado también para saltar ciertos caracteres)

  • . - cualquier carácter (except newline character)

  • - comienza con

  • - termina con

  • {} - Exactly the specified number of occurrences

  • | - Either or - Used to easily combine regex with two or more functions

  • () - captura y agrupa

  1. Set de descripciones

  • [0123] - Returns a match where any of the specified digits (0, 1, 2, or 3) are present

  • [0-9] - Returns a match for any digit between 0 and 9

  • [0-5][0-9] - Returns a match for any two-digit numbers from 00 and 59

Ejemplos

  1. ^([1-9]|1[012])$ 

  • ^ -  Anchors the regex at the start of the string

  • [1-9] - Matches 1 to 9

  • | - Basically used when you want to combine two or more regex - alternation matches the previous match or the following match.

  • 1[012] - Matches 10, 11, or 12

  • $ - Anchors the regex at the end of the string.

  1. ^2[0-9]{10}$ - Allows 10 Digits starting with a 2. 

  1. ^[0]{1}[1-9]{1}[0-9]{8}$ - Values need to have alteast 10 digits starting with a 0

  2. ^237[0-9]{9}$ - Values need to have at least 12 digits starting with 237

El mejor sitio para usar para formular Regex y probarlos es Regex101. Por favor, pruebe estos Regex primero antes de implementarlos en los flujos de trabajo / lista.