freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-an.../regular-expressions/match-all-letters-and-numbe...

3.7 KiB
Raw Blame History

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

Description

Usando clases de caracteres, pudiste 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 ( _ ).
sea longHand = / [A-Za-z0-9 _] + /;
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
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>&quot;The five boxing wizards jump quickly.&quot;</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>&quot;Pack my box with five dozen liquor jugs.&quot;</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>&quot;How vexingly quick daft zebras jump!&quot;</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>&quot;123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.&quot;</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