3.7 KiB
3.7 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db7367417b2b2512b9f | Match All Letters and Numbers | 1 | Unir todas las letras y números |
Description
[az]
. Este tipo de clase de caracteres es lo suficientemente común como para que haya un atajo, aunque también incluye algunos caracteres adicionales. La clase de caracteres más cercana en JavaScript para que coincida con el alfabeto es \w
. Este atajo es igual a [A-Za-z0-9_]
. Esta clase de caracteres coincide con mayúsculas y minúsculas más números. Tenga en cuenta que esta clase de caracteres también incluye el carácter de subrayado ( _
). sea longHand = / [A-Za-z0-9 _] + /;Estas clases de caracteres de acceso directo también se conocen como
deja shortHand = / \ w + /;
dejar números = "42";
deja varNames = "important_var";
longHand.test (números); // Devuelve true
shortHand.test (números); // Devuelve true
longHand.test (varNames); // Devuelve true
shortHand.test (varNames); // Devuelve true
shorthand character classes
. Instructions
\w
para contar el número de caracteres alfanuméricos en varias comillas y cadenas. Tests
tests:
- text: Su expresión regular debe utilizar la bandera global.
testString: 'assert(alphabetRegexV2.global, "Your regex should use the global flag.");'
- text: Tu expresión regular debe usar el carácter abreviado
testString: 'assert(/\\w/.test(alphabetRegexV2.source), "Your regex should use the shorthand character <code>\w</code> to match all characters which are alphanumeric.");'
- text: Su expresión regular debe encontrar 31 caracteres alfanuméricos en <code>"The five boxing wizards jump quickly."</code>
testString: 'assert("The five boxing wizards jump quickly.".match(alphabetRegexV2).length === 31, "Your regex should find 31 alphanumeric characters in <code>"The five boxing wizards jump quickly."</code>");'
- text: Su expresión regular debe encontrar 32 caracteres alfanuméricos en <code>"Pack my box with five dozen liquor jugs."</code>
testString: 'assert("Pack my box with five dozen liquor jugs.".match(alphabetRegexV2).length === 32, "Your regex should find 32 alphanumeric characters in <code>"Pack my box with five dozen liquor jugs."</code>");'
- text: Tu expresión regular debe encontrar 30 caracteres alfanuméricos en <code>"How vexingly quick daft zebras jump!"</code>
testString: 'assert("How vexingly quick daft zebras jump!".match(alphabetRegexV2).length === 30, "Your regex should find 30 alphanumeric characters in <code>"How vexingly quick daft zebras jump!"</code>");'
- text: Su expresión regular debe encontrar 36 caracteres alfanuméricos en <code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>
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 <code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>");'
Challenge Seed
let quoteSample = "The five boxing wizards jump quickly.";
let alphabetRegexV2 = /change/; // Change this line
let result = quoteSample.match(alphabetRegexV2).length;
Solution
// solution required