<sectionid="description"> Ha aprendido que puede usar un atajo para hacer coincidir los caracteres alfanuméricos <code>[A-Za-z0-9_]</code> usando <code>\w</code> . Un patrón natural que quizás desee buscar es el opuesto a los alfanuméricos. Puedes buscar lo contrario de <code>\w</code> con <code>\W</code> Tenga en cuenta, el patrón opuesto utiliza una letra mayúscula. Este atajo es el mismo que <code>[^A-Za-z0-9_]</code> . <blockquote> deja shortHand = / \ W /; <br> dejar números = "42%"; <br> let sentence = "Coding!"; <br> numbers.match (shortHand); // Devoluciones ["%"] <br> sentence.match (shortHand); // Devoluciones ["!"] <br></blockquote></section>
<sectionid="instructions"> Use la clase de caracteres abreviados <code>\W</code> para contar el número de caracteres no alfanuméricos en varias comillas y cadenas. </section>
testString: 'assert("The five boxing wizards jump quickly.".match(nonAlphabetRegex).length == 6, "Your regex should find 6 non-alphanumeric characters in <code>"The five boxing wizards jump quickly."</code>.");'
- text: Tu expresión regular debe usar el carácter de taquigrafía.
testString: 'assert(/\\W/.test(nonAlphabetRegex.source), "Your regex should use the shorthand character to match characters which are non-alphanumeric.");'
testString: 'assert("Pack my box with five dozen liquor jugs.".match(nonAlphabetRegex).length == 8, "Your regex should find 8 non-alphanumeric characters in <code>"Pack my box with five dozen liquor jugs."</code>");'