[az]
. Esse tipo de classe de caracteres é comum o suficiente para que haja um atalho para ele, embora inclua alguns caracteres extras também. A classe de caractere mais próxima em JavaScript para corresponder ao alfabeto é \w
. Este atalho é igual a [A-Za-z0-9_]
. Essa classe de caracteres corresponde a letras maiúsculas e minúsculas mais números. Note que esta classe de caracteres também inclui o caractere de sublinhado ( _
). let longHand = / [A-Za-z0-9 _] + /;Essas classes de caracteres de atalho também são conhecidas como
deixe shortHand = / \ w + /;
deixe números = "42";
deixe varNames = "important_var";
longHand.test (números); // Retorna true
shortHand.test (números); // Retorna true
longHand.test (varNames); // Retorna true
shortHand.test (varNames); // Retorna true
shorthand character classes
. \w
para contar o número de caracteres alfanuméricos em várias aspas e cadeias de caracteres. \w
to match all characters which are alphanumeric.");'
- text: Seu regex deve encontrar 31 caracteres alfanuméricos em "The five boxing wizards jump quickly."
testString: 'assert("The five boxing wizards jump quickly.".match(alphabetRegexV2).length === 31, "Your regex should find 31 alphanumeric characters in "The five boxing wizards jump quickly."
");'
- text: Seu regex deve encontrar 32 caracteres alfanuméricos em "Pack my box with five dozen liquor jugs."
testString: 'assert("Pack my box with five dozen liquor jugs.".match(alphabetRegexV2).length === 32, "Your regex should find 32 alphanumeric characters in "Pack my box with five dozen liquor jugs."
");'
- text: Seu regex deve encontrar 30 caracteres alfanuméricos em "How vexingly quick daft zebras jump!"
testString: 'assert("How vexingly quick daft zebras jump!".match(alphabetRegexV2).length === 30, "Your regex should find 30 alphanumeric characters in "How vexingly quick daft zebras jump!"
");'
- text: Seu regex deve encontrar 36 caracteres alfanuméricos em "123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."
testString: 'assert("123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.".match(alphabetRegexV2).length === 36, "Your regex should find 36 alphanumeric characters in "123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."
");'
```