2018-10-08 17:34:43 +00:00
---
id: 5d712346c441eddfaeb5bdef
title: Match All Numbers
challengeType: 1
2018-10-10 20:20:40 +00:00
videoUrl: ''
localeTitle: Coincidir todos los números
2018-10-08 17:34:43 +00:00
---
## Description
2018-10-10 20:20:40 +00:00
< section id = "description" > Has aprendido atajos para patrones de cadena comunes como alfanuméricos. Otro patrón común es buscar solo dígitos o números. El atajo para buscar caracteres de dígitos es < code > \d</ code > , con una < code > d</ code > minúscula. Esto es igual a la clase de caracteres < code > [0-9]</ code > , que busca un solo carácter de cualquier número entre cero y nueve. </ section >
2018-10-08 17:34:43 +00:00
## Instructions
2018-10-10 20:20:40 +00:00
< section id = "instructions" > Use la clase de caracteres abreviados < code > \d</ code > para contar cuántos dígitos hay en los títulos de las películas. Los números escritos (" seis" en lugar de 6) no cuentan. </ section >
2018-10-08 17:34:43 +00:00
## Tests
< section id = 'tests' >
```yml
tests:
- text: Tu expresión regular debe usar el atajo para coincidir con los dígitos.
testString: 'assert(/\\d/.test(numRegex.source), "Your regex should use the shortcut character to match digit characters");'
- text: Su expresión regular debe utilizar la bandera global.
testString: 'assert(numRegex.global, "Your regex should use the global flag.");'
2018-10-10 20:20:40 +00:00
- text: Su expresión regular debe encontrar 1 dígito en < code > " 9" </ code > .
2018-10-08 17:34:43 +00:00
testString: 'assert("9".match(numRegex).length == 1, "Your regex should find 1 digit in < code > "9"< / code > .");'
2018-10-10 20:20:40 +00:00
- text: Su expresión regular debe encontrar 2 dígitos en < code > " Catch 22" </ code > .
2018-10-08 17:34:43 +00:00
testString: 'assert("Catch 22".match(numRegex).length == 2, "Your regex should find 2 digits in < code > "Catch 22"< / code > .");'
2018-10-10 20:20:40 +00:00
- text: Su expresión regular debe encontrar 3 dígitos en < code > " 101 Dalmatians" </ code > .
2018-10-08 17:34:43 +00:00
testString: 'assert("101 Dalmatians".match(numRegex).length == 3, "Your regex should find 3 digits in < code > "101 Dalmatians"< / code > .");'
2018-10-10 20:20:40 +00:00
- text: 'Su expresión regular no debe encontrar dígitos en < code > " One, Two, Three" </ code > .'
2018-10-08 17:34:43 +00:00
testString: 'assert("One, Two, Three".match(numRegex) == null, "Your regex should find no digits in < code > "One, Two, Three"< / code > .");'
2018-10-10 20:20:40 +00:00
- text: Su expresión regular debe encontrar 2 dígitos en < code > " 21 Jump Street" </ code > .
2018-10-08 17:34:43 +00:00
testString: 'assert("21 Jump Street".match(numRegex).length == 2, "Your regex should find 2 digits in < code > "21 Jump Street"< / code > .");'
2018-10-10 20:20:40 +00:00
- text: 'Su expresión regular debe encontrar 4 dígitos en < code > " 2001: A Space Odyssey" </ code > .'
2018-10-08 17:34:43 +00:00
testString: 'assert("2001: A Space Odyssey".match(numRegex).length == 4, "Your regex should find 4 digits in < code > "2001: A Space Odyssey"< / code > .");'
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
let numString = "Your sandwich will be $5.00";
let numRegex = /change/; // Change this line
let result = numString.match(numRegex).length;
2018-10-10 20:20:40 +00:00
2018-10-08 17:34:43 +00:00
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
// solution required
```
< / section >