-
) para hacer coincidir un rango de caracteres no se limita a las letras. También funciona para hacer coincidir un rango de números.
Por ejemplo, /[0-5]/
coincide con cualquier número entre 0
y 5
, incluidos 0
y 5
.
Además, es posible combinar un rango de letras y números en un solo conjunto de caracteres.
let jennyStr = "Jenny8675309";
let myRegex = /[a-z0-9]/ig;
// matches all letters and numbers in jennyStr
jennyStr.match(myRegex);
h
y s
, y una gama de números de entre 2
y 6
. Recuerde incluir las banderas apropiadas en la expresión regular.
myRegex
debe coincidir con 17 elementos.
testString: 'assert(result.length == 17, "Your regex myRegex
should match 17 items.");'
- text: Su regex myRegex
debe usar la bandera global.
testString: 'assert(myRegex.flags.match(/g/).length == 1, "Your regex myRegex
should use the global flag.");'
- text: Su expresión regular myRegex
debe usar la myRegex
no distingue entre mayúsculas y minúsculas.
testString: 'assert(myRegex.flags.match(/i/).length == 1, "Your regex myRegex
should use the case insensitive flag.");'
```