Files
freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-and-data-structures/regular-expressions/match-all-letters-and-numbers.spanish.md
2018-10-08 13:34:43 -04:00

3.7 KiB

id, title, localeTitle, challengeType
id title localeTitle challengeType
587d7db7367417b2b2512b9f Match All Letters and Numbers Unir todas las letras y números 1

Description

Al usar clases de caracteres, pudo buscar todas las letras del alfabeto con [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 ( _ ).
let longHand = /[A-Za-z0-9_]+/;
let shortHand = /\w+/;
let numbers = "42";
let varNames = "important_var";
longHand.test(numbers); // Returns true
shortHand.test(numbers); // Returns true
longHand.test(varNames); // Returns true
shortHand.test(varNames); // Returns true
Estas clases de caracteres de acceso directo también se conocen como shorthand character classes .

Instructions

Use la clase de caracteres abreviados \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 clase = "notranslate"> "Los cinco magos de boxeo saltan rápidamente". </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 clase = "notranslate"> "Empaque mi caja con cinco docenas de jarras de licor". </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 clase = "notranslate"> "¡Cómo saltan las cebras!" </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 <código clase = "notranslate"> "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