chore(i18n,curriculum): processed translations (#42868)

This commit is contained in:
camperbot
2021-07-16 11:03:16 +05:30
committed by GitHub
parent 1f5f07cad3
commit 3b32da0191
429 changed files with 7502 additions and 4006 deletions

View File

@ -1,6 +1,6 @@
---
id: 587d7dba367417b2b2512ba8
title: Check for All or None
title: Verificando existência
challengeType: 1
forumTopicId: 301338
dashedName: check-for-all-or-none
@ -8,11 +8,11 @@ dashedName: check-for-all-or-none
# --description--
Sometimes the patterns you want to search for may have parts of it that may or may not exist. However, it may be important to check for them nonetheless.
Haverá vezes em que você procurará padrões que podem ou não existir na string. Pode ser relevante validá-los dependendo da situação.
You can specify the possible existence of an element with a question mark, `?`. This checks for zero or one of the preceding element. You can think of this symbol as saying the previous element is optional.
Você pode fazer com que um padrão seja opcional ao usar uma interrogação, `?`, depois dele. Ela valida se há uma ou nenhuma ocorrência do padrão. Pode-se dizer que a interrogação torna o elemento à esquerda dela opcional.
For example, there are slight differences in American and British English and you can use the question mark to match both spellings.
Por exemplo, com a interrogação você pode capturar palavras em inglês escritas com a ortografia americana ou britânica.
```js
let american = "color";
@ -22,36 +22,36 @@ rainbowRegex.test(american);
rainbowRegex.test(british);
```
Both uses of the `test` method would return `true`.
Ambas as chamadas ao método `test` retornam `true`.
# --instructions--
Change the regex `favRegex` to match both the American English (`favorite`) and the British English (`favourite`) version of the word.
Altere a regex `favRegex` para encontrar as versões americana (`favorite`) e britânica (`favourite`) da palavra.
# --hints--
Your regex should use the optional symbol, `?`.
Sua regex deve usar a interrogação (`?`) para validação opcional.
```js
favRegex.lastIndex = 0;
assert(favRegex.source.match(/\?/).length > 0);
```
Your regex should match the string `favorite`
Sua regex deve encontrar a string `favorite`
```js
favRegex.lastIndex = 0;
assert(favRegex.test('favorite'));
```
Your regex should match the string `favourite`
Sua regex deve encontrar a string `favourite`
```js
favRegex.lastIndex = 0;
assert(favRegex.test('favourite'));
```
Your regex should not match the string `fav`
Sua regex não deve encontrar a string `fav`
```js
favRegex.lastIndex = 0;

View File

@ -1,6 +1,6 @@
---
id: 5c3dda8b4d8df89bea71600f
title: Check For Mixed Grouping of Characters
title: Validando Grupos Mistos de Caracteres
challengeType: 1
forumTopicId: 301339
dashedName: check-for-mixed-grouping-of-characters
@ -8,11 +8,11 @@ dashedName: check-for-mixed-grouping-of-characters
# --description--
Sometimes we want to check for groups of characters using a Regular Expression and to achieve that we use parentheses `()`.
Há vezes em que queremos validar grupos de caracteres em uma expressão regular. É possível fazê-lo usando parênteses: `()`.
If you want to find either `Penguin` or `Pumpkin` in a string, you can use the following Regular Expression: `/P(engu|umpk)in/g`
Você pode usar a expressão regular `/P(engu|umpk)in/g` para encontrar tanto `Penguin` quanto `Pumpkin` em uma string.
Then check whether the desired string groups are in the test string by using the `test()` method.
Depois é só usar o método `test()` para verificar se os grupos estão presentes na string.
```js
let testStr = "Pumpkin";
@ -20,51 +20,51 @@ let testRegex = /P(engu|umpk)in/;
testRegex.test(testStr);
```
The `test` method here would return `true`.
O método `test` retorna `true` aqui.
# --instructions--
Fix the regex so that it checks for the names of `Franklin Roosevelt` or `Eleanor Roosevelt` in a case sensitive manner and it should make concessions for middle names.
Corrija a regex para que ela valide os nomes `Franklin Roosevelt` e `Eleanor Roosevelt` levando em conta maiúsculas e minúsculas. A regex também deve permitir nomes do meio.
Then fix the code so that the regex that you have created is checked against `myString` and either `true` or `false` is returned depending on whether the regex matches.
Depois corrija o código, fazendo com que a regex seja testada na string `myString`, retornando `true` ou `false`.
# --hints--
Your regex `myRegex` should return `true` for the string `Franklin D. Roosevelt`
Sua regex `myRegex` deve retornar `true` para a string `Franklin D. Roosevelt`
```js
myRegex.lastIndex = 0;
assert(myRegex.test('Franklin D. Roosevelt'));
```
Your regex `myRegex` should return `true` for the string `Eleanor Roosevelt`
Sua regex `myRegex` deve retornar `true` para a string `Eleanor Roosevelt`
```js
myRegex.lastIndex = 0;
assert(myRegex.test('Eleanor Roosevelt'));
```
Your regex `myRegex` should return `false` for the string `Franklin Rosevelt`
Sua regex `myRegex` deve retornar `false` para a string `Franklin Rosevelt`
```js
myRegex.lastIndex = 0;
assert(!myRegex.test('Franklin Rosevelt'));
```
Your regex `myRegex` should return `false` for the string `Frank Roosevelt`
Sua regex `myRegex` deve retornar `false` para a string `Frank Roosevelt`
```js
myRegex.lastIndex = 0;
assert(!myRegex.test('Frank Roosevelt'));
```
You should use `.test()` to test the regex.
Você deve usar `.test()` para testar a regex.
```js
assert(code.match(/myRegex.test\(\s*myString\s*\)/));
```
Your result should return `true`.
O resultado deve ser `true`.
```js
assert(result === true);

View File

@ -1,6 +1,6 @@
---
id: 587d7db4367417b2b2512b92
title: Extract Matches
title: Extraindo Resultados
challengeType: 1
forumTopicId: 301340
dashedName: extract-matches
@ -8,11 +8,11 @@ dashedName: extract-matches
# --description--
So far, you have only been checking if a pattern exists or not within a string. You can also extract the actual matches you found with the `.match()` method.
Até agora, você só tem verificado se existe ou não um padrão dentro de uma string. Você também pode extrair os resultados encontrados por meio do método `.match()`.
To use the `.match()` method, apply the method on a string and pass in the regex inside the parentheses.
Para usar o método `.match()`, aplique o método em uma string e passe a regex dentro dos parênteses.
Here's an example:
Um exemplo:
```js
"Hello, World!".match(/Hello/);
@ -21,9 +21,9 @@ let ourRegex = /expressions/;
ourStr.match(ourRegex);
```
Here the first `match` would return `["Hello"]` and the second would return `["expressions"]`.
Aqui, o primeiro `match` retorna `["Hello"]` e, o segundo, `["expressions"]`.
Note that the `.match` syntax is the "opposite" of the `.test` method you have been using thus far:
Note que o método `.match` se usa de forma "contrária" ao método `.test` que você usou até então:
```js
'string'.match(/regex/);
@ -32,23 +32,23 @@ Note that the `.match` syntax is the "opposite" of the `.test` method you have b
# --instructions--
Apply the `.match()` method to extract the string `coding`.
Aplique o método `.match()` para extrair a string `coding`.
# --hints--
The `result` should have the string `coding`
O resultado, `result`, deve conter a string `coding`
```js
assert(result.join() === 'coding');
```
Your regex `codingRegex` should search for the string `coding`
Sua regex `codingRegex` deve buscar a string `coding`
```js
assert(codingRegex.source === 'coding');
```
You should use the `.match()` method.
Você deve usar o método `.match()`.
```js
assert(code.match(/\.match\(.*\)/));

View File

@ -1,6 +1,6 @@
---
id: 587d7db6367417b2b2512b9b
title: Find Characters with Lazy Matching
title: Encontre Caracteres com Captura Preguiçosa
challengeType: 1
forumTopicId: 301341
dashedName: find-characters-with-lazy-matching
@ -8,35 +8,35 @@ dashedName: find-characters-with-lazy-matching
# --description--
In regular expressions, a <dfn>greedy</dfn> match finds the longest possible part of a string that fits the regex pattern and returns it as a match. The alternative is called a <dfn>lazy</dfn> match, which finds the smallest possible part of the string that satisfies the regex pattern.
Em expressões regulares, uma captura <dfn>gananciosa</dfn> encontra a parte mais longa o possível de uma string em que a regex atua e a retorna como resultado. A alternativa se chama captura <dfn>preguiçosa</dfn> e ela encontra o menor pedaço o possível de uma string que satisfaz a regex.
You can apply the regex `/t[a-z]*i/` to the string `"titanic"`. This regex is basically a pattern that starts with `t`, ends with `i`, and has some letters in between.
Você pode aplicar a regex `/t[a-z]*i/` à string `"titanic"`. Essa regex é basicamente um padrão que começa com `t`, termina com `i`e tem algumas letras no meio delas.
Regular expressions are by default greedy, so the match would return `["titani"]`. It finds the largest sub-string possible to fit the pattern.
Expressões regulares são gananciosas por padrão, então o resultado seria `["titani"]`. Ou seja, a maior string o possível que atende ao padrão é encontrada.
However, you can use the `?` character to change it to lazy matching. `"titanic"` matched against the adjusted regex of `/t[a-z]*?i/` returns `["ti"]`.
Mas você pode usar o caractere `?` para torná-la preguiçosa. Aplicar a regex adaptada `/t[a-z]*?i/` à string `"titanic"` retorna `["ti"]`.
**Note:** Parsing HTML with regular expressions should be avoided, but pattern matching an HTML string with regular expressions is completely fine.
**Obs:** Ler HTML com expressões regulares deve ser evitado, mas procurar uma string HTML usando expressões regulares é perfeitamente aceitável.
# --instructions--
Fix the regex `/<.*>/` to return the HTML tag `<h1>` and not the text `"<h1>Winter is coming</h1>"`. Remember the wildcard `.` in a regular expression matches any character.
Arrume a regex `/<.*>/` para que retorne a tag HTML `<h1>` mas não a linha `"<h1>Winter is coming</h1>"`. Lembre-se de que o caractere curinga `.` em uma expressão regular captura qualquer caractere.
# --hints--
The `result` variable should be an array with `<h1>` in it
A variável `result` deve ser um array contendo `<h1>`
```js
assert(result[0] == '<h1>');
```
`myRegex` should use lazy matching
`myRegex` deve ser preguiçosa
```js
assert(/\?/g.test(myRegex));
```
`myRegex` should not include the string `h1`
`myRegex` não deve incluir a string `h1`
```js
assert(!myRegex.source.match('h1'));

View File

@ -1,6 +1,6 @@
---
id: 587d7db4367417b2b2512b93
title: Find More Than the First Match
title: Encontre Mais do que o Primeiro Resultado
challengeType: 1
forumTopicId: 301342
dashedName: find-more-than-the-first-match
@ -8,7 +8,7 @@ dashedName: find-more-than-the-first-match
# --description--
So far, you have only been able to extract or search a pattern once.
Até agora você foi capaz apenas de extrair ou buscar um resultado de uma vez.
```js
let testStr = "Repeat, Repeat, Repeat";
@ -16,39 +16,39 @@ let ourRegex = /Repeat/;
testStr.match(ourRegex);
```
Here `match` would return `["Repeat"]`.
`match` retorna `["Repeat"]` aqui.
To search or extract a pattern more than once, you can use the `g` flag.
Para buscar ou extrair um padrão além do primeiro resultado, você pode usar a flag `g` (de "global").
```js
let repeatRegex = /Repeat/g;
testStr.match(repeatRegex);
```
And here `match` returns the value `["Repeat", "Repeat", "Repeat"]`
Aqui, `match` retorna o valor `["Repeat", "Repeat", "Repeat"]`
# --instructions--
Using the regex `starRegex`, find and extract both `Twinkle` words from the string `twinkleStar`.
Usando a regex `starRegex`, encontre e extraia ambas ocorrências da palavra `Twinkle` da string `twinkleStar`.
**Note**
You can have multiple flags on your regex like `/search/gi`
**Obs:**
Você pode usar múltiplas flags em uma regex: `/search/gi`
# --hints--
Your regex `starRegex` should use the global flag `g`
Sua regex `starRegex` deve usar a flag `g`
```js
assert(starRegex.flags.match(/g/).length == 1);
```
Your regex `starRegex` should use the case insensitive flag `i`
Sua regex `starRegex` deve usar a flag de ignorar caixa, `i`
```js
assert(starRegex.flags.match(/i/).length == 1);
```
Your match should match both occurrences of the word `Twinkle`
Seu resultado deve conter ambas as ocorrências da palavra `Twinkle`
```js
assert(
@ -60,7 +60,7 @@ assert(
);
```
Your match `result` should have two elements in it.
Seu resultado, `result`, deve conter dois elementos.
```js
assert(result.length == 2);

View File

@ -1,6 +1,6 @@
---
id: 587d7db7367417b2b2512b9c
title: Find One or More Criminals in a Hunt
title: Encontre Um ou Mais Criminosos em uma Caçada
challengeType: 1
forumTopicId: 301343
dashedName: find-one-or-more-criminals-in-a-hunt
@ -8,11 +8,11 @@ dashedName: find-one-or-more-criminals-in-a-hunt
# --description--
Time to pause and test your new regex writing skills. A group of criminals escaped from jail and ran away, but you don't know how many. However, you do know that they stay close together when they are around other people. You are responsible for finding all of the criminals at once.
Hora de testar as suas novas habilidades de regex. Um grupo de criminosos escapou da prisão, mas não sabemos quantos. No entanto, sabemos que eles ficam juntos quando estão no meio de outras pessoas. E você ficou responsável por encontrar todos eles.
Here's an example to review how to do this:
Vamos revisitar maneiras de executar essa tarefa:
The regex `/z+/` matches the letter `z` when it appears one or more times in a row. It would find matches in all of the following strings:
A regex `/z+/` encontra a letra `z` quando ela aparece uma ou mais vezes seguidas. Ela encontra resultados em todas essas strings:
```js
"z"
@ -22,7 +22,7 @@ The regex `/z+/` matches the letter `z` when it appears one or more times in a r
"abczzzzzzzzzzzzzzzzzzzzzabc"
```
But it does not find matches in the following strings since there are no letter `z` characters:
Mas ela não encontra nada nessas strings, que não possuem `z` em lugar nenhum:
```js
""
@ -32,23 +32,23 @@ But it does not find matches in the following strings since there are no letter
# --instructions--
Write a greedy regex that finds one or more criminals within a group of other people. A criminal is represented by the capital letter `C`.
Escreva uma regex gananciosa que encontra uma ou mais criminosos em um grupo de pessoas. Um criminoso pode ser identificado pela letra maiúscula `C`.
# --hints--
Your regex should match one criminal (`C`) in the string `C`
Sua regex deve encontrar um criminoso (`C`) na string `C`
```js
assert('C'.match(reCriminals) && 'C'.match(reCriminals)[0] == 'C');
```
Your regex should match two criminals (`CC`) in the string `CC`
Sua regex deve encontrar dois criminosos (`CC`) na string `CC`
```js
assert('CC'.match(reCriminals) && 'CC'.match(reCriminals)[0] == 'CC');
```
Your regex should match three criminals (`CCC`) in the string `P1P5P4CCCcP2P6P3`.
Sua regex deve encontrar três criminosos (`CCC`) na string `P1P5P4CCCcP2P6P3`.
```js
assert(
@ -57,7 +57,7 @@ assert(
);
```
Your regex should match five criminals (`CCCCC`) in the string `P6P2P7P4P5CCCCCP3P1`
Sua regex deve encontrar cinco criminosos (`CCCCC`) na string `P6P2P7P4P5CCCCCP3P1`
```js
assert(
@ -66,19 +66,19 @@ assert(
);
```
Your regex should not match any criminals in the empty string `""`
Sua regex não deve encontrar nenhum criminoso na string vazia `""`
```js
assert(!reCriminals.test(''));
```
Your regex should not match any criminals in the string `P1P2P3`
Sua regex não deve encontrar nenhum criminoso na string `P1P2P3`
```js
assert(!reCriminals.test('P1P2P3'));
```
Your regex should match fifty criminals (`CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC`) in the string `P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3`.
Sua regex deve encontrar cinquenta criminosos (`CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC`) na string `P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3`.
```js
assert(

View File

@ -1,6 +1,6 @@
---
id: 587d7db4367417b2b2512b91
title: Ignore Case While Matching
title: Ignore a Caixa ao Buscar
challengeType: 1
forumTopicId: 301344
dashedName: ignore-case-while-matching
@ -8,73 +8,73 @@ dashedName: ignore-case-while-matching
# --description--
Up until now, you've looked at regexes to do literal matches of strings. But sometimes, you might want to also match case differences.
Até agora você escreveu regexes para encontrar strings literais. Mas, às vezes, você pode querer encontrar caixas diferentes.
Case (or sometimes letter case) is the difference between uppercase letters and lowercase letters. Examples of uppercase are `A`, `B`, and `C`. Examples of lowercase are `a`, `b`, and `c`.
Caixa (-alta ou -baixa) é a diferença entre letras maiúsculas e minúsculas. São exemplos de caixa alta: `A`, `B` e `C`. `a`, `b` e `c` são exemplos de caixa baixa.
You can match both cases using what is called a flag. There are other flags but here you'll focus on the flag that ignores case - the `i` flag. You can use it by appending it to the regex. An example of using this flag is `/ignorecase/i`. This regex can match the strings `ignorecase`, `igNoreCase`, and `IgnoreCase`.
Você pode encontrar ambas as caixas usando algo que chamamos de <dfn>flag</dfn>. Existem várias flags, mas agora nós queremos a flag que ignora a caixa - a flag `i`. Para usá-la é só colocar ao fim da regex. Por exemplo, escrever `/ignorecase/i` é uma forma. Essa regex pode encontrar as strings `ignorecase`, `igNoreCase` e `IgnoreCase` (e todas as outras combinações de maiúsculas e minúsculas).
# --instructions--
Write a regex `fccRegex` to match `freeCodeCamp`, no matter its case. Your regex should not match any abbreviations or variations with spaces.
Escreva uma regex `fccRegex` que encontre `freeCodeCamp`, não importa em que caixa esteja. Sua regex não deve buscar abreviações ou variações com espaços.
# --hints--
Your regex should match the string `freeCodeCamp`
Sua regex deve encontrar a string `freeCodeCamp`
```js
assert(fccRegex.test('freeCodeCamp'));
```
Your regex should match the string `FreeCodeCamp`
Sua regex deve encontrar a string `FreeCodeCamp`
```js
assert(fccRegex.test('FreeCodeCamp'));
```
Your regex should match the string `FreecodeCamp`
Sua regex deve encontrar a string `FreecodeCamp`
```js
assert(fccRegex.test('FreecodeCamp'));
```
Your regex should match the string `FreeCodecamp`
Sua regex deve encontrar a string `FreeCodecamp`
```js
assert(fccRegex.test('FreeCodecamp'));
```
Your regex should not match the string `Free Code Camp`
Sua regex não deve encontrar a string `Free Code Camp`
```js
assert(!fccRegex.test('Free Code Camp'));
```
Your regex should match the string `FreeCOdeCamp`
Sua regex deve encontrar a string `FreeCOdeCamp`
```js
assert(fccRegex.test('FreeCOdeCamp'));
```
Your regex should not match the string `FCC`
Sua regex não deve encontrar a string `FCC`
```js
assert(!fccRegex.test('FCC'));
```
Your regex should match the string `FrEeCoDeCamp`
Sua regex deve encontrar a string `FrEeCoDeCamp`
```js
assert(fccRegex.test('FrEeCoDeCamp'));
```
Your regex should match the string `FrEeCodECamp`
Sua regex deve encontrar a string `FrEeCodECamp`
```js
assert(fccRegex.test('FrEeCodECamp'));
```
Your regex should match the string `FReeCodeCAmp`
Sua regex deve encontrar a string `FReeCodeCAmp`
```js
assert(fccRegex.test('FReeCodeCAmp'));

View File

@ -1,6 +1,6 @@
---
id: 587d7db4367417b2b2512b90
title: Match a Literal String with Different Possibilities
title: Busque uma String Literal com Diferentes Possibilidades
challengeType: 1
forumTopicId: 301345
dashedName: match-a-literal-string-with-different-possibilities
@ -8,57 +8,57 @@ dashedName: match-a-literal-string-with-different-possibilities
# --description--
Using regexes like `/coding/`, you can look for the pattern `coding` in another string.
Ao usar regexes como `/coding/`, você pode procurar pelo padrão `coding` em strings.
This is powerful to search single strings, but it's limited to only one pattern. You can search for multiple patterns using the `alternation` or `OR` operator: `|`.
Isso funciona com strings únicas, mas é limitado a apenas um padrão. Você pode procurar por múltiplos padrões usando o operador de `alternação`, ou `OU`: `|`.
This operator matches patterns either before or after it. For example, if you wanted to match the strings `yes` or `no`, the regex you want is `/yes|no/`.
Este operador funciona para buscar padrões à esquerda e à direita dele. Por exemplo, se você quiser encontrar as strings `yes` ou `no`, a regex que você quer é `/yes|no/`.
You can also search for more than just two patterns. You can do this by adding more patterns with more `OR` operators separating them, like `/yes|no|maybe/`.
Você pode também procurar por mais de dois padrões com este operador. É possível fazer isso ao adicionar mais instâncias do operador seguido do padrão desejado: `/yes|no|maybe/`.
# --instructions--
Complete the regex `petRegex` to match the pets `dog`, `cat`, `bird`, or `fish`.
Complete a regex `petRegex` para encontrar os pets `dog`, `cat`, `bird`, ou `fish`.
# --hints--
Your regex `petRegex` should return `true` for the string `John has a pet dog.`
Sua regex `petRegex` deve retornar `true` para a string `John has a pet dog.`
```js
assert(petRegex.test('John has a pet dog.'));
```
Your regex `petRegex` should return `false` for the string `Emma has a pet rock.`
Sua regex `petRegex` deve retornar `false` para a string `Emma has a pet rock.`
```js
assert(!petRegex.test('Emma has a pet rock.'));
```
Your regex `petRegex` should return `true` for the string `Emma has a pet bird.`
Sua regex `petRegex` deve retornar `true` para a string `Emma has a pet bird.`
```js
assert(petRegex.test('Emma has a pet bird.'));
```
Your regex `petRegex` should return `true` for the string `Liz has a pet cat.`
Sua regex `petRegex` deve retornar `true` para a string `Liz has a pet cat.`
```js
assert(petRegex.test('Liz has a pet cat.'));
```
Your regex `petRegex` should return `false` for the string `Kara has a pet dolphin.`
Sua regex `petRegex` deve retornar `false` para a string `Kara has a pet dolphin.`
```js
assert(!petRegex.test('Kara has a pet dolphin.'));
```
Your regex `petRegex` should return `true` for the string `Alice has a pet fish.`
Sua regex `petRegex` deve retornar `true` para a string `Alice has a pet fish.`
```js
assert(petRegex.test('Alice has a pet fish.'));
```
Your regex `petRegex` should return `false` for the string `Jimmy has a pet computer.`
Sua regex `petRegex` deve retornar `false` para a string `Jimmy has a pet computer.`
```js
assert(!petRegex.test('Jimmy has a pet computer.'));

View File

@ -1,6 +1,6 @@
---
id: 587d7db7367417b2b2512b9f
title: Match All Letters and Numbers
title: Capture Todas as Letras e Números
challengeType: 1
forumTopicId: 301346
dashedName: match-all-letters-and-numbers
@ -8,9 +8,9 @@ dashedName: match-all-letters-and-numbers
# --description--
Using character classes, you were able to search for all letters of the alphabet with `[a-z]`. This kind of character class is common enough that there is a shortcut for it, although it includes a few extra characters as well.
Ao escrever `[a-z]` você foi capaz de capturar todas as letras do alfabeto. Essa classe de caracteres é tão comum que existe uma forma reduzida de escrevê-la. Mas essa forma inclui alguns caracteres a mais.
The closest character class in JavaScript to match the alphabet is `\w`. This shortcut is equal to `[A-Za-z0-9_]`. This character class matches upper and lowercase letters plus numbers. Note, this character class also includes the underscore character (`_`).
Em JavaScript, você pode usar `\w` para capturar todas as letras do alfabeto. Isso é equivalente à classe de caracteres `[A-Za-z0-9_]`. Ela captura números e letras, tanto maiúsculas quanto minúsculas. Note que o underline (`_`) também é incluído nela.
```js
let longHand = /[A-Za-z0-9_]+/;
@ -23,29 +23,29 @@ longHand.test(varNames);
shortHand.test(varNames);
```
All four of these `test` calls would return `true`.
As quatro chamadas a `test` retornam `true`.
These shortcut character classes are also known as <dfn>shorthand character classes</dfn>.
Essas formas reduzidas de classes de caracteres podem ser chamadas de <dfn>atalhos</dfn>.
# --instructions--
Use the shorthand character class `\w` to count the number of alphanumeric characters in various quotes and strings.
Use o atalho `\w` para contar o número de caracteres alfanuméricos em várias strings.
# --hints--
Your regex should use the global flag.
Sua regex deve usar a flag global.
```js
assert(alphabetRegexV2.global);
```
Your regex should use the shorthand character `\w` to match all characters which are alphanumeric.
Sua regex deve usar o atalho `\w` para capturar todos os caracteres alfanuméricos.
```js
assert(/\\w/.test(alphabetRegexV2.source));
```
Your regex should find 31 alphanumeric characters in the string `The five boxing wizards jump quickly.`
Sua regex deve encontrar 31 caracteres alfanuméricos na string `The five boxing wizards jump quickly.`
```js
assert(
@ -53,7 +53,7 @@ assert(
);
```
Your regex should find 32 alphanumeric characters in the string `Pack my box with five dozen liquor jugs.`
Sua regex deve encontrar 32 caracteres alfanuméricos na string `Pack my box with five dozen liquor jugs.`
```js
assert(
@ -62,7 +62,7 @@ assert(
);
```
Your regex should find 30 alphanumeric characters in the string `How vexingly quick daft zebras jump!`
Sua regex deve encontrar 30 caracteres alfanuméricos na string `How vexingly quick daft zebras jump!`
```js
assert(
@ -70,7 +70,7 @@ assert(
);
```
Your regex should find 36 alphanumeric characters in the string `123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.`
Sua regex deve encontrar 36 caracteres alfanuméricos na string `123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.`
```js
assert(

View File

@ -1,6 +1,6 @@
---
id: 587d7db8367417b2b2512ba1
title: Match All Non-Numbers
title: Capture Tudo Exceto Números
challengeType: 1
forumTopicId: 301347
dashedName: match-all-non-numbers
@ -8,59 +8,59 @@ dashedName: match-all-non-numbers
# --description--
The last challenge showed how to search for digits using the shortcut `\d` with a lowercase `d`. You can also search for non-digits using a similar shortcut that uses an uppercase `D` instead.
O último desafio mostrou como procurar dígitos usando o atalho `\d` com um `d` minúsculo. Você também pode procurar não-dígitos usando um atalho semelhante que usa um `D` maiúsculo.
The shortcut to look for non-digit characters is `\D`. This is equal to the character class `[^0-9]`, which looks for a single character that is not a number between zero and nine.
O atalho para procurar não-dígitos é `\D`. Esse atalho é o mesmo que `[^0-9]`, que serve para procurar qualquer caractere que não seja um dígito de zero a nove.
# --instructions--
Use the shorthand character class for non-digits `\D` to count how many non-digits are in movie titles.
Use o atalho `\D` para contar quantos não-dígitos existem em títulos de filmes.
# --hints--
Your regex should use the shortcut character to match non-digit characters
Sua regex deve usar o atalho que captura não-dígitos
```js
assert(/\\D/.test(noNumRegex.source));
```
Your regex should use the global flag.
Sua regex deve usar a flag global.
```js
assert(noNumRegex.global);
```
Your regex should find no non-digits in the string `9`.
Sua regex não deve encontrar nenhum não-dígito na string `9`.
```js
assert('9'.match(noNumRegex) == null);
```
Your regex should find 6 non-digits in the string `Catch 22`.
Sua regex deve encontrar seis não-dígitos na string `Catch 22`.
```js
assert('Catch 22'.match(noNumRegex).length == 6);
```
Your regex should find 11 non-digits in the string `101 Dalmatians`.
Sua regex deve encontrar onze não-dígitos na string `101 Dalmatians`.
```js
assert('101 Dalmatians'.match(noNumRegex).length == 11);
```
Your regex should find 15 non-digits in the string `One, Two, Three`.
Sua regex deve encontrar quinze não-dígitos na string `One, Two, Three`.
```js
assert('One, Two, Three'.match(noNumRegex).length == 15);
```
Your regex should find 12 non-digits in the string `21 Jump Street`.
Sua regex deve encontrar 12 não-dígitos na string `21 Jump Street`.
```js
assert('21 Jump Street'.match(noNumRegex).length == 12);
```
Your regex should find 17 non-digits in the string `2001: A Space Odyssey`.
Sua regex deve encontrar dezessete não-dígitos na string `2001: A Space Odyssey`.
```js
assert('2001: A Space Odyssey'.match(noNumRegex).length == 17);

View File

@ -1,6 +1,6 @@
---
id: 5d712346c441eddfaeb5bdef
title: Match All Numbers
title: Capture Todos os Números
challengeType: 1
forumTopicId: 18181
dashedName: match-all-numbers
@ -8,59 +8,59 @@ dashedName: match-all-numbers
# --description--
You've learned shortcuts for common string patterns like alphanumerics. Another common pattern is looking for just digits or numbers.
Você aprendeu atalhos para padrões comuns de strings como alfanuméricos. Outro padrão comum é o de apenas dígitos ou números.
The shortcut to look for digit characters is `\d`, with a lowercase `d`. This is equal to the character class `[0-9]`, which looks for a single character of any number between zero and nine.
O atalho para procurar caracteres numéricos é `\d`, com um `d` minúsculo. Esse atalho é o mesmo que `[0-9]`, que serve para procurar qualquer dígito de zero a nove.
# --instructions--
Use the shorthand character class `\d` to count how many digits are in movie titles. Written out numbers ("six" instead of 6) do not count.
Use o atalho `\d` para contar quantos dígitos existem em títulos de filmes. Números por extenso, como "seis" em vez de 6, não contam.
# --hints--
Your regex should use the shortcut character to match digit characters
Sua regex deve usar o atalho que captura dígitos
```js
assert(/\\d/.test(numRegex.source));
```
Your regex should use the global flag.
Sua regex deve usar a flag global.
```js
assert(numRegex.global);
```
Your regex should find 1 digit in the string `9`.
Sua regex deve encontrar um dígito na string `9`.
```js
assert('9'.match(numRegex).length == 1);
```
Your regex should find 2 digits in the string `Catch 22`.
Sua regex deve encontrar dois dígitos na string `Catch 22`.
```js
assert('Catch 22'.match(numRegex).length == 2);
```
Your regex should find 3 digits in the string `101 Dalmatians`.
Sua regex deve encontrar três dígitos na string `101 Dalmatians`.
```js
assert('101 Dalmatians'.match(numRegex).length == 3);
```
Your regex should find no digits in the string `One, Two, Three`.
Sua regex não deve encontrar dígito algum na string `One, Two, Three`.
```js
assert('One, Two, Three'.match(numRegex) == null);
```
Your regex should find 2 digits in the string `21 Jump Street`.
Sua regex deve encontrar dois dígitos na string `21 Jump Street`.
```js
assert('21 Jump Street'.match(numRegex).length == 2);
```
Your regex should find 4 digits in the string `2001: A Space Odyssey`.
Sua regex deve encontrar quatro dígitos na string `2001: A Space Odyssey`.
```js
assert('2001: A Space Odyssey'.match(numRegex).length == 4);

View File

@ -1,6 +1,6 @@
---
id: 587d7db5367417b2b2512b94
title: Match Anything with Wildcard Period
title: Encontre Qualquer Coisa com o Caractere Curinga
challengeType: 1
forumTopicId: 301348
dashedName: match-anything-with-wildcard-period
@ -8,9 +8,9 @@ dashedName: match-anything-with-wildcard-period
# --description--
Sometimes you won't (or don't need to) know the exact characters in your patterns. Thinking of all words that match, say, a misspelling would take a long time. Luckily, you can save time using the wildcard character: `.`
Haverá vezes em que você não saberá (ou não precisará saber) quais caracteres exatamente farão parte das suas regexes. Pensar em todas as palavras que capturariam, digamos, um erro ortográfico levaria muito tempo. Por sorte, você pode economizar tempo usando o caractere curinga: `.`
The wildcard character `.` will match any one character. The wildcard is also called `dot` and `period`. You can use the wildcard character just like any other character in the regex. For example, if you wanted to match `hug`, `huh`, `hut`, and `hum`, you can use the regex `/hu./` to match all four words.
O caractere curinga `.` captura qualquer caractere. O curinga também pode ser chamado de `ponto`. Você pode usar o curinga como qualquer outro caractere na regex. Por exemplo, se você quiser encontrar `hug`, `huh`, `hut` ou `hum`, você pode usar a regex `/hu./` para capturar todas as quatro palavras.
```js
let humStr = "I'll hum a song";
@ -20,62 +20,62 @@ huRegex.test(humStr);
huRegex.test(hugStr);
```
Both of these `test` calls would return `true`.
As duas chamadas a `test` retornam `true`.
# --instructions--
Complete the regex `unRegex` so that it matches the strings `run`, `sun`, `fun`, `pun`, `nun`, and `bun`. Your regex should use the wildcard character.
Complete a regex `unRegex` para que ela encontre as strings `run`, `sun`, `fun`, `pun`, `nun` e `bun`. Sua regex deve usar o caractere curinga.
# --hints--
You should use the `.test()` method.
Você deve usar o método `.test()`.
```js
assert(code.match(/\.test\(.*\)/));
```
You should use the wildcard character in your regex `unRegex`
Você deve usar o caractere curinga na regex `unRegex`
```js
assert(/\./.test(unRegex.source));
```
Your regex `unRegex` should match `run` in the string `Let us go on a run.`
Sua regex `unRegex` deve encontrar `run` na string `Let us go on a run.`
```js
unRegex.lastIndex = 0;
assert(unRegex.test('Let us go on a run.'));
```
Your regex `unRegex` should match `sun` in the string `The sun is out today.`
Sua regex `unRegex` deve encontrar `sun` na string `The sun is out today.`
```js
unRegex.lastIndex = 0;
assert(unRegex.test('The sun is out today.'));
```
Your regex `unRegex` should match `fun` in the string `Coding is a lot of fun.`
Sua regex `unRegex` deve encontrar `fun` na string `Coding is a lot of fun.`
```js
unRegex.lastIndex = 0;
assert(unRegex.test('Coding is a lot of fun.'));
```
Your regex `unRegex` should match `pun` in the string `Seven days without a pun makes one weak.`
Sua regex `unRegex` deve encontrar `pun` na string `Seven days without a pun makes one weak.`
```js
unRegex.lastIndex = 0;
assert(unRegex.test('Seven days without a pun makes one weak.'));
```
Your regex `unRegex` should match `nun` in the string `One takes a vow to be a nun.`
Sua regex `unRegex` deve encontrar `nun` na string `One takes a vow to be a nun.`
```js
unRegex.lastIndex = 0;
assert(unRegex.test('One takes a vow to be a nun.'));
```
Your regex `unRegex` should match `bun` in the string `She got fired from the hot dog stand for putting her hair in a bun.`
Sua regex `unRegex` deve encontrar `bun` na string `She got fired from the hot dog stand for putting her hair in a bun.`
```js
unRegex.lastIndex = 0;
@ -86,14 +86,14 @@ assert(
);
```
Your regex `unRegex` should not match the string `There is a bug in my code.`
Sua regex `unRegex` não deve incluir a string `There is a bug in my code.` no resultado
```js
unRegex.lastIndex = 0;
assert(!unRegex.test('There is a bug in my code.'));
```
Your regex `unRegex` should not match the string `Catch me if you can.`
Sua regex `unRegex` não deve incluir a string `Catch me if you can.` no resultado
```js
unRegex.lastIndex = 0;

View File

@ -1,6 +1,6 @@
---
id: 587d7db7367417b2b2512b9d
title: Match Beginning String Patterns
title: Padrões de Início de String
challengeType: 1
forumTopicId: 301349
dashedName: match-beginning-string-patterns
@ -8,9 +8,9 @@ dashedName: match-beginning-string-patterns
# --description--
Prior challenges showed that regular expressions can be used to look for a number of matches. They are also used to search for patterns in specific positions in strings.
Desafios anteriores mostraram que expressões regulares podem ser usadas para capturar um número de resultados. Elas também podem ser usadas para procurar em posições específicas de strings.
In an earlier challenge, you used the caret character (`^`) inside a character set to create a negated character set in the form `[^thingsThatWillNotBeMatched]`. Outside of a character set, the caret is used to search for patterns at the beginning of strings.
Mais cedo você usou o circunflexo (`^`) em classes de caracteres para procurar caracteres que não devem ser capturados, como em `[^caracteresQueNãoQueremos]`. Quando usados fora de classes de caracteres, o circunflexo serve para buscar a partir do começo de strings.
```js
let firstString = "Ricky is first and can be found.";
@ -20,33 +20,33 @@ let notFirst = "You can't find Ricky now.";
firstRegex.test(notFirst);
```
The first `test` call would return `true`, while the second would return `false`.
A primeira chamada a `test` retorna `true` enquanto a segunda retorna `false`.
# --instructions--
Use the caret character in a regex to find `Cal` only in the beginning of the string `rickyAndCal`.
Use o circunflexo em uma regex para encontrar `Cal`, mas apenas no começo da string `rickyAndCal`.
# --hints--
Your regex should search for the string `Cal` with a capital letter.
Sua regex deve buscar a string `Cal` com uma maiúscula.
```js
assert(calRegex.source == '^Cal');
```
Your regex should not use any flags.
Sua regex não deve usar nenhuma flag.
```js
assert(calRegex.flags == '');
```
Your regex should match the string `Cal` at the beginning of the string.
Sua regex deve capturar a string `Cal` no começo de uma string.
```js
assert(calRegex.test('Cal and Ricky both like racing.'));
```
Your regex should not match the string `Cal` in the middle of a string.
Sua regex não deve capturar a string `Cal` no meio de uma string.
```js
assert(!calRegex.test('Ricky and Cal both like racing.'));

View File

@ -1,6 +1,6 @@
---
id: 587d7db6367417b2b2512b99
title: Match Characters that Occur One or More Times
title: Capture Caracteres que Aparecem Uma ou Mais Vezes Seguidas
challengeType: 1
forumTopicId: 301350
dashedName: match-characters-that-occur-one-or-more-times
@ -8,33 +8,33 @@ dashedName: match-characters-that-occur-one-or-more-times
# --description--
Sometimes, you need to match a character (or group of characters) that appears one or more times in a row. This means it occurs at least once, and may be repeated.
Às vezes você precisa capturar um caractere, ou grupo de caracteres, que aparece uma ou mais vezes seguidas. Ou seja, que aparecem pelo menos uma vez e podem se repetir.
You can use the `+` character to check if that is the case. Remember, the character or pattern has to be present consecutively. That is, the character has to repeat one after the other.
Você pode usar o caractere `+` para verificar se é o caso. Lembre-se que o caractere ou padrão precisa repetir-se consecutivamente. Ou seja, um atrás do outro.
For example, `/a+/g` would find one match in `abc` and return `["a"]`. Because of the `+`, it would also find a single match in `aabc` and return `["aa"]`.
Por exemplo, `/a+/g` encontra um resultado na string `abc` e retorna `["a"]`. Mas o `+` também faz com que encontre um único resultado em `aabc` e retorne `["aa"]`.
If it were instead checking the string `abab`, it would find two matches and return `["a", "a"]` because the `a` characters are not in a row - there is a `b` between them. Finally, since there is no `a` in the string `bcd`, it wouldn't find a match.
Se a string fosse `abab`, a operação retornaria `["a", "a"]` porque entre os dois `a` há um `b`. Por fim, se não houvesse nenhum `a` na string, como em `bcd`, nada seria encontrado.
# --instructions--
You want to find matches when the letter `s` occurs one or more times in `Mississippi`. Write a regex that uses the `+` sign.
Você quer capturar as ocorrências de `s` quando acontecer uma ou mais vezes em `Mississippi`. Escreve uma regex que use o caractere `+`.
# --hints--
Your regex `myRegex` should use the `+` sign to match one or more `s` characters.
Sua regex `myRegex` deve usar o caractere `+` para encontrar um ou mais `s`s.
```js
assert(/\+/.test(myRegex.source));
```
Your regex `myRegex` should match 2 items.
Sua regex `myRegex` deve encontrar 2 itens.
```js
assert(result.length == 2);
```
The `result` variable should be an array with two matches of `ss`
A variável `result` deve ser um array com dois `ss`
```js
assert(result[0] == 'ss' && result[1] == 'ss');

View File

@ -1,6 +1,6 @@
---
id: 587d7db6367417b2b2512b9a
title: Match Characters that Occur Zero or More Times
title: Capture Caracteres que Aparecem Zero ou Mais Vezes Seguidas
challengeType: 1
forumTopicId: 301351
dashedName: match-characters-that-occur-zero-or-more-times
@ -8,9 +8,9 @@ dashedName: match-characters-that-occur-zero-or-more-times
# --description--
The last challenge used the plus `+` sign to look for characters that occur one or more times. There's also an option that matches characters that occur zero or more times.
O último desafio fez uso do caractere `+` para buscar caracteres que ocorrem uma ou mais vezes. Existe um outro caractere que permite buscar zero ou mais ocorrências de um padrão.
The character to do this is the asterisk or star: `*`.
O caractere usado para isso é o asterisco: `*`.
```js
let soccerWord = "gooooooooal!";
@ -22,39 +22,39 @@ gPhrase.match(goRegex);
oPhrase.match(goRegex);
```
In order, the three `match` calls would return the values `["goooooooo"]`, `["g"]`, and `null`.
As três chamadas a `match` retornam, na ordem, os valores: `["goooooooo"]`, `["g"]` e `null`.
# --instructions--
For this challenge, `chewieQuote` has been initialized as the string `Aaaaaaaaaaaaaaaarrrgh!` behind the scenes. Create a regex `chewieRegex` that uses the `*` character to match an uppercase `A` character immediately followed by zero or more lowercase `a` characters in `chewieQuote`. Your regex does not need flags or character classes, and it should not match any of the other quotes.
Neste desafio, a string `chewieQuote` recebeu o valor `Aaaaaaaaaaaaaaaarrrgh!` por trás dos panos. Escreva uma regex, `chewieRegex`, que usa o caractere `*` para capturar um `A` maiúsculo seguido imediatamente de zero ou mais `a` minúsculos em `chewieQuote`. Sua regex não precisa de flags ou de classes de caracteres. Ela também não deve capturar nenhuma outra parte da string.
# --hints--
Your regex `chewieRegex` should use the `*` character to match zero or more `a` characters.
Sua regex `chewieRegex` deve usar o caractere `*` para encontrar zero ou mais `a`s.
```js
assert(/\*/.test(chewieRegex.source));
```
Your regex should match the string `A` in `chewieQuote`.
Sua regex deve encontrar a string `A` em `chewieQuote`.
```js
assert(result[0][0] === 'A');
```
Your regex should match the string `Aaaaaaaaaaaaaaaa` in `chewieQuote`.
Sua regex deve encontrar a string `Aaaaaaaaaaaaaaaa` em `chewieQuote`.
```js
assert(result[0] === 'Aaaaaaaaaaaaaaaa');
```
Your regex `chewieRegex` should match 16 characters in `chewieQuote`.
Sua regex `chewieRegex` deve capturar 16 caracteres em `chewieQuote`.
```js
assert(result[0].length === 16);
```
Your regex should not match any characters in the string `He made a fair move. Screaming about it can't help you.`
Sua expressão regular não deve corresponder com nenhum caractere na string `He made a fair move. Screaming about it can't help you.`
```js
assert(
@ -62,7 +62,7 @@ assert(
);
```
Your regex should not match any characters in the string `Let him have it. It's not wise to upset a Wookiee.`
Sua expressão regular não deve corresponder a nenhum caractere na string `Let him have it. It's not wise to upset a Wookiee.`
```js
assert(

View File

@ -1,6 +1,6 @@
---
id: 587d7db7367417b2b2512b9e
title: Match Ending String Patterns
title: Padrões de Fim de String
challengeType: 1
forumTopicId: 301352
dashedName: match-ending-string-patterns
@ -8,9 +8,9 @@ dashedName: match-ending-string-patterns
# --description--
In the last challenge, you learned to use the caret character to search for patterns at the beginning of strings. There is also a way to search for patterns at the end of strings.
No desafio anterior, você aprendeu a usar o circunflexo para capturar padrões no início de strings. Há também uma maneira de buscar padrões no fim de strings.
You can search the end of strings using the dollar sign character `$` at the end of the regex.
Se você colocar um cifrão, `$`, no fim da regex, você pode buscar no fim de strings.
```js
let theEnding = "This is a never ending story";
@ -20,27 +20,27 @@ let noEnding = "Sometimes a story will have to end";
storyRegex.test(noEnding);
```
The first `test` call would return `true`, while the second would return `false`.
A primeira chamada a `test` retorna `true` enquanto a segunda retorna `false`.
# --instructions--
Use the anchor character (`$`) to match the string `caboose` at the end of the string `caboose`.
Use o cifrão (`$`) para capturar a string `caboose` no fim da string `caboose`.
# --hints--
You should search for `caboose` with the dollar sign `$` anchor in your regex.
Você deve usar o cifrão `$` na sua regex para buscar a string `caboose`.
```js
assert(lastRegex.source == 'caboose$');
```
Your regex should not use any flags.
Sua regex não deve usar nenhuma flag.
```js
assert(lastRegex.flags == '');
```
You should match `caboose` at the end of the string `The last car on a train is the caboose`
Você deve capturar `caboose` no fim da string `The last car on a train is the caboose`
```js
assert(lastRegex.test('The last car on a train is the caboose'));

View File

@ -1,6 +1,6 @@
---
id: 587d7db8367417b2b2512ba0
title: Match Everything But Letters and Numbers
title: Capture Tudo Exceto Letras e Números
challengeType: 1
forumTopicId: 301353
dashedName: match-everything-but-letters-and-numbers
@ -8,9 +8,9 @@ dashedName: match-everything-but-letters-and-numbers
# --description--
You've learned that you can use a shortcut to match alphanumerics `[A-Za-z0-9_]` using `\w`. A natural pattern you might want to search for is the opposite of alphanumerics.
Você aprendeu que você pode usar um atalho para capturar alfanuméricos `[A-Za-z0-9_]` usando `\w`. Você pode querer capturar exatamente o oposto disso.
You can search for the opposite of the `\w` with `\W`. Note, the opposite pattern uses a capital letter. This shortcut is the same as `[^A-Za-z0-9_]`.
Você pode capturar não-alfanuméricos usando `\W` ao invés de `\w`. Observe que o atalho usa uma maiúscula. Este atalho é o mesmo que escrever `[^A-Za-z0-9_]`.
```js
let shortHand = /\W/;
@ -20,21 +20,21 @@ numbers.match(shortHand);
sentence.match(shortHand);
```
The first `match` call would return the value `["%"]` and the second would return `["!"]`.
A primeira chamada a `match` retorna `["%"]` enquanto o segundo retorna `["!"]`.
# --instructions--
Use the shorthand character class `\W` to count the number of non-alphanumeric characters in various quotes and strings.
Use o atalho `\W` para contar o número de caracteres não-alfanuméricos em várias strings.
# --hints--
Your regex should use the global flag.
Sua regex deve usar a flag global.
```js
assert(nonAlphabetRegex.global);
```
Your regex should find 6 non-alphanumeric characters in the string `The five boxing wizards jump quickly.`.
Sua regex deve encontrar 6 caracteres não-alfanuméricos na string `The five boxing wizards jump quickly.`.
```js
assert(
@ -42,13 +42,13 @@ assert(
);
```
Your regex should use the shorthand character to match characters which are non-alphanumeric.
Sua regex deve usar o atalho que captura os caracteres não-alfanuméricos.
```js
assert(/\\W/.test(nonAlphabetRegex.source));
```
Your regex should find 8 non-alphanumeric characters in the string `Pack my box with five dozen liquor jugs.`
Sua regex deve encontrar 8 caracteres não-alfanuméricos na string `Pack my box with five dozen liquor jugs.`
```js
assert(
@ -56,7 +56,7 @@ assert(
);
```
Your regex should find 6 non-alphanumeric characters in the string `How vexingly quick daft zebras jump!`
Sua regex deve encontrar 6 caracteres não-alfanuméricos na string `How vexingly quick daft zebras jump!`
```js
assert(
@ -64,7 +64,7 @@ assert(
);
```
Your regex should find 12 non-alphanumeric characters in the string `123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.`
Sua regex deve encontrar 12 caracteres não-alfanuméricos na string `123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.`
```js
assert(

View File

@ -1,6 +1,6 @@
---
id: 587d7db5367417b2b2512b96
title: Match Letters of the Alphabet
title: Capture Letras do Alfabeto
challengeType: 1
forumTopicId: 301354
dashedName: match-letters-of-the-alphabet
@ -8,11 +8,11 @@ dashedName: match-letters-of-the-alphabet
# --description--
You saw how you can use <dfn>character sets</dfn> to specify a group of characters to match, but that's a lot of typing when you need to match a large range of characters (for example, every letter in the alphabet). Fortunately, there is a built-in feature that makes this short and simple.
Você viu como pode usar <dfn>classes de caracteres</dfn> para especificar um grupo de caracteres para capturar. Mas você precisaria escrever muito para definir uma classe larga como, por exemplo, para capturar todas as letras do alfabeto. Felizmente há uma maneira de fazer com que elas fiquem pequenas e simples.
Inside a character set, you can define a range of characters to match using a hyphen character: `-`.
Você pode usar um hífen (`-`) para definir um intervalo de caracteres para capturar dentro de uma classe.
For example, to match lowercase letters `a` through `e` you would use `[a-e]`.
Por exemplo, para encontrar letras minúsculas de `a` a `e`, você pode escrever `[a-e]`.
```js
let catStr = "cat";
@ -24,29 +24,29 @@ batStr.match(bgRegex);
matStr.match(bgRegex);
```
In order, the three `match` calls would return the values `["cat"]`, `["bat"]`, and `null`.
As três chamadas a `match` retornam, na ordem, os valores: `["cat"]`, `["bat"]` e `null`.
# --instructions--
Match all the letters in the string `quoteSample`.
Capture todas as letras na string `quoteSample`.
**Note**: Be sure to match both uppercase and lowercase letters.
**Nota:** Você quer encontrar tanto maiúsculas quanto minúsculas.
# --hints--
Your regex `alphabetRegex` should match 35 items.
Sua regex `alphabetRegex` deve encontrar 35 itens.
```js
assert(result.length == 35);
```
Your regex `alphabetRegex` should use the global flag.
Você deve usar a flag global na sua regex `alphabetRegex`.
```js
assert(alphabetRegex.flags.match(/g/).length == 1);
```
Your regex `alphabetRegex` should use the case insensitive flag.
Você deve usar a flag de ignorar caixa na sua regex `alphabetRegex`.
```js
assert(alphabetRegex.flags.match(/i/).length == 1);

View File

@ -1,6 +1,6 @@
---
id: 587d7db3367417b2b2512b8f
title: Match Literal Strings
title: Correspondência de strings literais
challengeType: 1
forumTopicId: 301355
dashedName: match-literal-strings
@ -8,7 +8,7 @@ dashedName: match-literal-strings
# --description--
In the last challenge, you searched for the word `Hello` using the regular expression `/Hello/`. That regex searched for a literal match of the string `Hello`. Here's another example searching for a literal match of the string `Kevin`:
No desafio anterior, você usou a expressão regular `/Hello/` para procurar a palavra `Hello`. Esta regex buscou a string `Hello` literalmente. No exemplo abaixo há outra busca literal, dessa vez pela string `Kevin`:
```js
let testStr = "Hello, my name is Kevin.";
@ -16,38 +16,38 @@ let testRegex = /Kevin/;
testRegex.test(testStr);
```
This `test` call will return `true`.
Essa chamada a `test` retornará `true`.
Any other forms of `Kevin` will not match. For example, the regex `/Kevin/` will not match `kevin` or `KEVIN`.
Qualquer outra forma de escrever `Kevin` não funcionará. Por exemplo, a regex `/Kevin/` não encontrará nem `kevin` e nem `KEVIN`.
```js
let wrongRegex = /kevin/;
wrongRegex.test(testStr);
```
This `test` call will return `false`.
`test` retornará `false`.
A future challenge will show how to match those other forms as well.
Você verá como encontrar estas outras formas em alguns desafios futuros.
# --instructions--
Complete the regex `waldoRegex` to find `"Waldo"` in the string `waldoIsHiding` with a literal match.
Complete a regex `waldoRegex` para encontrar `"Waldo"` na string `waldoIsHiding` de forma literal.
# --hints--
Your regex `waldoRegex` should find the string `Waldo`
Sua regex `waldoRegex` deve encontrar a string `Waldo`
```js
assert(waldoRegex.test(waldoIsHiding));
```
Your regex `waldoRegex` should not search for anything else.
Sua regex `waldoRegex` não deve buscar nada além disso.
```js
assert(!waldoRegex.test('Somewhere is hiding in this text.'));
```
You should perform a literal string match with your regex.
A busca com a regex deve ser por uma string literal.
```js
assert(!/\/.*\/i/.test(code));

View File

@ -1,6 +1,6 @@
---
id: 587d7db9367417b2b2512ba4
title: Match Non-Whitespace Characters
title: Capture Caracteres Não-Espaço
challengeType: 1
forumTopicId: 18210
dashedName: match-non-whitespace-characters
@ -8,9 +8,9 @@ dashedName: match-non-whitespace-characters
# --description--
You learned about searching for whitespace using `\s`, with a lowercase `s`. You can also search for everything except whitespace.
Você aprendeu a procurar por espaço em branco usando `\s` com um `s` minúsculo. Você também pode buscar tudo exceto espaços em branco.
Search for non-whitespace using `\S`, which is an uppercase `s`. This pattern will not match whitespace, carriage return, tab, form feed, and new line characters. You can think of it being similar to the character class `[^ \r\t\f\n\v]`.
Busque não-espaços em branco usando `\S` com um `s` maiúsculo. Este atalho não captura espaços em branco, retorno de carro, tabulações, feeds de formulário ou quebras de linha. O atalho é equivalente à classe de caracteres `[^ \r\t\f\n\v]`.
```js
let whiteSpace = "Whitespace. Whitespace everywhere!"
@ -18,27 +18,27 @@ let nonSpaceRegex = /\S/g;
whiteSpace.match(nonSpaceRegex).length;
```
The value returned by the `.length` method would be `32`.
O valor retornado pelo método `.length` aqui é `32`.
# --instructions--
Change the regex `countNonWhiteSpace` to look for multiple non-whitespace characters in a string.
Modifique a regex `countNonWhiteSpace` para que encontre tudo exceto espaços em branco em uma string.
# --hints--
Your regex should use the global flag.
Sua regex deve usar a flag global.
```js
assert(countNonWhiteSpace.global);
```
Your regex should use the shorthand character `\S` to match all non-whitespace characters.
Sua regex deve usar o atalho `\S` para capturar tudo menos espaços em branco.
```js
assert(/\\S/.test(countNonWhiteSpace.source));
```
Your regex should find 35 non-spaces in the string `Men are from Mars and women are from Venus.`
Sua regex deve encontrar 35 não-espaços na string `Men are from Mars and women are from Venus.`
```js
assert(
@ -47,13 +47,13 @@ assert(
);
```
Your regex should find 23 non-spaces in the string `Space: the final frontier.`
Sua regex deve encontrar 23 não-espaços na string `Space: the final frontier.`
```js
assert('Space: the final frontier.'.match(countNonWhiteSpace).length == 23);
```
Your regex should find 21 non-spaces in the string `MindYourPersonalSpace`
Sua regex deve encontrar 21 não-espaços na string `MindYourPersonalSpace`
```js
assert('MindYourPersonalSpace'.match(countNonWhiteSpace).length == 21);

View File

@ -1,6 +1,6 @@
---
id: 587d7db5367417b2b2512b97
title: Match Numbers and Letters of the Alphabet
title: Capture Números e Letras do Alfabeto
challengeType: 1
forumTopicId: 301356
dashedName: match-numbers-and-letters-of-the-alphabet
@ -8,11 +8,11 @@ dashedName: match-numbers-and-letters-of-the-alphabet
# --description--
Using the hyphen (`-`) to match a range of characters is not limited to letters. It also works to match a range of numbers.
O uso do hífen (`-`) para capturar um intervalo de caracteres não é limitado a letras. Ele também funciona para capturar intervalos de números.
For example, `/[0-5]/` matches any number between `0` and `5`, including the `0` and `5`.
Por exemplo, `/[0-5]/` encontra qualquer número entre `0` e `5`, incluindo ambos `0` e `5`.
Also, it is possible to combine a range of letters and numbers in a single character set.
E também é possível combinar intervalos de letras e números em uma única classe de caracteres.
```js
let jennyStr = "Jenny8675309";
@ -22,23 +22,23 @@ jennyStr.match(myRegex);
# --instructions--
Create a single regex that matches a range of letters between `h` and `s`, and a range of numbers between `2` and `6`. Remember to include the appropriate flags in the regex.
Escreva uma única regex que encontra letras entre `h` e `s` e, também, números entre `2` e `6`. Lembre-se de incluir as flags necessárias na regex.
# --hints--
Your regex `myRegex` should match 17 items.
Sua regex `myRegex` deve encontrar 17 itens.
```js
assert(result.length == 17);
```
Your regex `myRegex` should use the global flag.
Você deve usar a flag global na sua regex `myRegex`.
```js
assert(myRegex.flags.match(/g/).length == 1);
```
Your regex `myRegex` should use the case insensitive flag.
Você deve usar a flag de ignorar caixa na sua regex `myRegex`.
```js
assert(myRegex.flags.match(/i/).length == 1);

View File

@ -1,6 +1,6 @@
---
id: 587d7db5367417b2b2512b95
title: Match Single Character with Multiple Possibilities
title: Capture um Único Caractere com Múltiplas Possibilidades
challengeType: 1
forumTopicId: 301357
dashedName: match-single-character-with-multiple-possibilities
@ -8,11 +8,11 @@ dashedName: match-single-character-with-multiple-possibilities
# --description--
You learned how to match literal patterns (`/literal/`) and wildcard character (`/./`). Those are the extremes of regular expressions, where one finds exact matches and the other matches everything. There are options that are a balance between the two extremes.
Você aprendeu a capturar padrões literais (`/literal/`) e usar o caractere curinga (`/./`). Eles são os extremos das expressões regulares: um encontra o texto exato e o outro captura qualquer coisa. Existem formas de balancear esses extremos.
You can search for a literal pattern with some flexibility with <dfn>character classes</dfn>. Character classes allow you to define a group of characters you wish to match by placing them inside square (`[` and `]`) brackets.
Você pode ter alguma flexibilidade ao procurar um padrão literal usando <dfn>classes de caracteres</dfn>. Classes de caracteres permitem a definição de grupos de caracteres que você quer capturar ao colocá-los entre colchetes: `[` e `]`.
For example, you want to match `bag`, `big`, and `bug` but not `bog`. You can create the regex `/b[aiu]g/` to do this. The `[aiu]` is the character class that will only match the characters `a`, `i`, or `u`.
Por exemplo, se você quiser encontrar `bag`, `big` e `bug` mas não `bog`. Você pode escrever a regex `/b[aiu]g/` para isso. `[aiu]` é a classe de caracteres que só capturará `a`, `i` ou `u`.
```js
let bigStr = "big";
@ -26,41 +26,41 @@ bugStr.match(bgRegex);
bogStr.match(bgRegex);
```
In order, the four `match` calls would return the values `["big"]`, `["bag"]`, `["bug"]`, and `null`.
As quatro chamadas a `match` retornarão os seguintes valores, nesta ordem: `["big"]`, `["bag"]`, `["bug"]` e `null`.
# --instructions--
Use a character class with vowels (`a`, `e`, `i`, `o`, `u`) in your regex `vowelRegex` to find all the vowels in the string `quoteSample`.
Use classe de caracteres de vogais (`a`, `e`, `i`, `o`, `u`) na sua regex `vowelRegex` para encontrar todas as vogais na string `quoteSample`.
**Note:** Be sure to match both upper- and lowercase vowels.
**Nota:** Você quer encontrar tanto maiúsculas quanto minúsculas.
# --hints--
You should find all 25 vowels.
Você deve encontrar todas as 25 vogais.
```js
assert(result.length == 25);
```
Your regex `vowelRegex` should use a character class.
Você deve usar uma classe de caracteres na sua regex `vowelRegex`.
```js
assert(/\[.*\]/.test(vowelRegex.source));
```
Your regex `vowelRegex` should use the global flag.
Você deve usar a flag global na sua regex `vowelRegex`.
```js
assert(vowelRegex.flags.match(/g/).length == 1);
```
Your regex `vowelRegex` should use the case insensitive flag.
Você deve usar a flag de ignorar caixa na sua regex `vowelRegex`.
```js
assert(vowelRegex.flags.match(/i/).length == 1);
```
Your regex should not match any consonants.
Sua regex não deve encontrar nenhuma consoante.
```js
assert(!/[b-df-hj-np-tv-z]/gi.test(result.join()));

View File

@ -1,6 +1,6 @@
---
id: 587d7db6367417b2b2512b98
title: Match Single Characters Not Specified
title: Capture Caracteres Não Especificados
challengeType: 1
forumTopicId: 301358
dashedName: match-single-characters-not-specified
@ -8,31 +8,31 @@ dashedName: match-single-characters-not-specified
# --description--
So far, you have created a set of characters that you want to match, but you could also create a set of characters that you do not want to match. These types of character sets are called <dfn>negated character sets</dfn>.
Até agora você aprendeu a criar classes de caracteres para capturar caracteres específicos, mas você também pode usá-las para capturar caracteres ausentes nelas. Esse tipo de classe de caracteres é chamada <dfn>classe de caracteres negada</dfn>.
To create a negated character set, you place a caret character (`^`) after the opening bracket and before the characters you do not want to match.
Para criar uma classe de caracteres negada, você só precisa colocar um acento circunflexo (`^`) depois do colchete de abertura e à esquerda dos caracteres que você quer evitar.
For example, `/[^aeiou]/gi` matches all characters that are not a vowel. Note that characters like `.`, `!`, `[`, `@`, `/` and white space are matched - the negated vowel character set only excludes the vowel characters.
Por exemplo, `/[^aeiou]/gi` encontra todos os caracteres que não são vogais. Observe que caracteres como `.`, `!`, `[`, `@`, `/` e espaços em branco são capturados - a classe de vogais negada apenas exclui os caracteres que são vogais.
# --instructions--
Create a single regex that matches all characters that are not a number or a vowel. Remember to include the appropriate flags in the regex.
Crie uma única regex que captura todos os caracteres que não são números ou vogais. Lembre-se de incluir as flags necessárias na regex.
# --hints--
Your regex `myRegex` should match 9 items.
Sua regex `myRegex` deve encontrar 9 itens.
```js
assert(result.length == 9);
```
Your regex `myRegex` should use the global flag.
Você deve usar a flag global na sua regex `myRegex`.
```js
assert(myRegex.flags.match(/g/).length == 1);
```
Your regex `myRegex` should use the case insensitive flag.
Você deve usar a flag de ignorar caixa na sua regex `myRegex`.
```js
assert(myRegex.flags.match(/i/).length == 1);

View File

@ -1,6 +1,6 @@
---
id: 587d7db8367417b2b2512ba3
title: Match Whitespace
title: Capture Espaço em Branco
challengeType: 1
forumTopicId: 301359
dashedName: match-whitespace
@ -8,9 +8,9 @@ dashedName: match-whitespace
# --description--
The challenges so far have covered matching letters of the alphabet and numbers. You can also match the whitespace or spaces between letters.
Os desafios até agora cobriram a captura de letras do alfabeto e números. Você também pode capturar espaços em branco e os espaços entre as letras.
You can search for whitespace using `\s`, which is a lowercase `s`. This pattern not only matches whitespace, but also carriage return, tab, form feed, and new line characters. You can think of it as similar to the character class `[ \r\t\f\n\v]`.
Você pode usar o atalho `\s` com um `s` minúsculo para capturar espaços em branco. Este atalho não captura apenas espaços em branco como também retorno de carro, tabulações, feeds de formulário e quebras de linha. O atalho é equivalente à classe de caracteres `[ \r\t\f\n\v]`.
```js
let whiteSpace = "Whitespace. Whitespace everywhere!"
@ -18,26 +18,26 @@ let spaceRegex = /\s/g;
whiteSpace.match(spaceRegex);
```
This `match` call would return `[" ", " "]`.
`match` retorna `[" ", " "]` aqui.
# --instructions--
Change the regex `countWhiteSpace` to look for multiple whitespace characters in a string.
Mude a regex `countWhiteSpace` para que capture múltiplos espaços em branco em strings.
# --hints--
Your regex should use the global flag.
Sua regex deve usar a flag global.
```js
assert(countWhiteSpace.global);
```
Your regex should use the shorthand character `\s` to match all whitespace characters.
Sua regex deve usar o atalho `\s` para capturar todos os espaços em branco.
```js
assert(/\\s/.test(countWhiteSpace.source));
```
Your regex should find eight spaces in the string `Men are from Mars and women are from Venus.`
Sua regex deve encontrar oito espaços na string `Men are from Mars and women are from Venus.`
```js
assert(
@ -46,13 +46,13 @@ assert(
);
```
Your regex should find three spaces in the string `Space: the final frontier.`
Sua regex deve encontrar três espaços na string `Space: the final frontier.`
```js
assert('Space: the final frontier.'.match(countWhiteSpace).length == 3);
```
Your regex should find no spaces in the string `MindYourPersonalSpace`
Sua regex não deve encontrar espaços na string `MindYourPersonalSpace`
```js
assert('MindYourPersonalSpace'.match(countWhiteSpace) == null);

View File

@ -1,6 +1,6 @@
---
id: 587d7dba367417b2b2512ba9
title: Positive and Negative Lookahead
title: Lookaheads positivos e negativos
challengeType: 1
forumTopicId: 301360
dashedName: positive-and-negative-lookahead
@ -8,15 +8,15 @@ dashedName: positive-and-negative-lookahead
# --description--
<dfn>Lookaheads</dfn> are patterns that tell JavaScript to look-ahead in your string to check for patterns further along. This can be useful when you want to search for multiple patterns over the same string.
<dfn>Lookaheads</dfn> ("olhar à frente") são padrões que dizem ao JavaScript para procurar outros padrões ao longo da string sem capturá-los. Eles podem ser úteis quando é necessário fazer diversas verificações na mesma string.
There are two kinds of lookaheads: <dfn>positive lookahead</dfn> and <dfn>negative lookahead</dfn>.
Existem dois tipos de lookahead: o <dfn>lookahead positivo</dfn> e o <dfn>lookahead negativo</dfn>.
A positive lookahead will look to make sure the element in the search pattern is there, but won't actually match it. A positive lookahead is used as `(?=...)` where the `...` is the required part that is not matched.
Lookaheads positivos garantem que o padrão especificado se encontra à frente, mas não o capturam. Usa-se `(?=...)`, onde `...` é o padrão a ser procurado, para escrever lookaheads positivos.
On the other hand, a negative lookahead will look to make sure the element in the search pattern is not there. A negative lookahead is used as `(?!...)` where the `...` is the pattern that you do not want to be there. The rest of the pattern is returned if the negative lookahead part is not present.
Lookaheads negativos, por outro lado, garantem que o padrão especificado não se encontra à sua frente na string. Para usar lookaheads negativos, escrevemos `(?!...)` onde `...` é o padrão que você quer ter certeza que não está lá. O restante do padrão é validado se o padrão do lookahead negativo estiver ausente.
Lookaheads are a bit confusing but some examples will help.
É fácil se confundir com lookaheads, mas uns exemplos podem ajudar.
```js
let quit = "qu";
@ -27,9 +27,9 @@ quit.match(quRegex);
noquit.match(qRegex);
```
Both of these `match` calls would return `["q"]`.
As duas chamadas a `match` retornam `["q"]`.
A more practical use of lookaheads is to check two or more patterns in one string. Here is a (naively) simple password checker that looks for between 3 and 6 characters and at least one number:
Validar dois padrões diferentes em uma string é considerado um uso mais prático de lookaheads. Neste não-tão-aprimorado validador de senhas, os lookaheads procuram por 3 a 6 caracteres e pelo menos um número, respectivamente, na string:
```js
let password = "abc123";
@ -39,59 +39,59 @@ checkPass.test(password);
# --instructions--
Use lookaheads in the `pwRegex` to match passwords that are greater than 5 characters long, and have two consecutive digits.
Faça com que `pwRegex` capture senhas que têm 5 ou mais caracteres e dois dígitos consecutivos usando lookaheads.
# --hints--
Your regex should use two positive `lookaheads`.
Sua regex deve usar dois `lookaheads` positivos.
```js
assert(pwRegex.source.match(/\(\?=.*?\)\(\?=.*?\)/) !== null);
```
Your regex should not match the string `astronaut`
Sua regex não deve encontrar a string `astronaut`
```js
assert(!pwRegex.test('astronaut'));
```
Your regex should not match the string `banan1`
Sua regex não deve encontrar a string `banan1`
```js
assert(!pwRegex.test('banan1'));
```
Your regex should match the string `bana12`
Sua regex deve encontrar a string `bana12`
```js
assert(pwRegex.test('bana12'));
```
Your regex should match the string `abc123`
Sua regex deve encontrar a string `abc123`
```js
assert(pwRegex.test('abc123'));
```
Your regex should not match the string `12345`
Sua regex não deve encontrar a string `12345`
```js
assert(!pwRegex.test('12345'));
```
Your regex should match the string `8pass99`
Sua regex deve encontrar a string `8pass99`
```js
assert(pwRegex.test('8pass99'));
```
Your regex should not match the string `1a2bcde`
Sua regex não deve encontrar a string `1a2bcde`
```js
assert(!pwRegex.test('1a2bcde'));
```
Your regex should match the string `astr1on11aut`
Sua regex deve encontrar a string `astr1on11aut`
```js
assert(pwRegex.test('astr1on11aut'));

View File

@ -1,6 +1,6 @@
---
id: 587d7dbb367417b2b2512bac
title: Remove Whitespace from Start and End
title: Removendo Espaço em Branco do Início e Fim de Strings
challengeType: 1
forumTopicId: 301362
dashedName: remove-whitespace-from-start-and-end
@ -8,29 +8,29 @@ dashedName: remove-whitespace-from-start-and-end
# --description--
Sometimes whitespace characters around strings are not wanted but are there. Typical processing of strings is to remove the whitespace at the start and end of it.
Às vezes, strings têm espaços em branco indesejados em seus inícios e fins. Uma operação muito comum de strings é remover esses espaços ao redor delas.
# --instructions--
Write a regex and use the appropriate string methods to remove whitespace at the beginning and end of strings.
Escreva uma regex que, junto dos métodos apropriados de string, remove os espaços em branco do começo e do fim delas.
**Note:** The `String.prototype.trim()` method would work here, but you'll need to complete this challenge using regular expressions.
**Nota:** Normalmente usaríamos `String.prototype.trim()` para isso, mas a sua tarefa é fazer o mesmo usando expressões regulares.
# --hints--
`result` should be equal to the string `Hello, World!`
`result` deve ser igual a `Hello, World!`
```js
assert(result === 'Hello, World!');
```
Your solution should not use the `String.prototype.trim()` method.
Você não deve usar o método `String.prototype.trim()` no seu código.
```js
assert(!code.match(/\.?[\s\S]*?trim/));
```
The `result` variable should not directly be set to a string
Você não deve atribuir uma string diretamente à variável `result`
```js
assert(!code.match(/result\s*=\s*["'`].*?["'`]/));

View File

@ -1,6 +1,6 @@
---
id: 587d7db8367417b2b2512ba2
title: Restrict Possible Usernames
title: Limitando Possíveis Nomes de Usuário
challengeType: 1
forumTopicId: 301363
dashedName: restrict-possible-usernames
@ -8,97 +8,97 @@ dashedName: restrict-possible-usernames
# --description--
Usernames are used everywhere on the internet. They are what give users a unique identity on their favorite sites.
Nomes de usuário (usernames) são usados em toda a Internet. São o que fazem com que tenham uma identidade única em seus sites favoritos.
You need to check all the usernames in a database. Here are some simple rules that users have to follow when creating their username.
Você precisa verificar todos os usernames em um banco de dados. Existem algumas regras que os usuários precisam seguir quando criam os seus usernames.
1) Usernames can only use alpha-numeric characters.
1) Nomes de usuário só podem conter caracteres alfanuméricos.
2) The only numbers in the username have to be at the end. There can be zero or more of them at the end. Username cannot start with the number.
2) Os números, se algum, precisam estar no fim da string. Pode haver zero ou mais números. Usernames não podem começar com números.
3) Username letters can be lowercase and uppercase.
3) As letras podem ser maiúsculas ou minúsculas.
4) Usernames have to be at least two characters long. A two-character username can only use alphabet letters as characters.
4) O tamanho de nomes de usuários precisa ser pelo menos dois. Um username de dois caracteres só pode conter letras.
# --instructions--
Change the regex `userCheck` to fit the constraints listed above.
Modifique a regex `userCheck` para que inclua as regras listadas.
# --hints--
Your regex should match the string `JACK`
Sua regex deve encontrar a string `JACK`
```js
assert(userCheck.test('JACK'));
```
Your regex should not match the string `J`
Sua regex não deve encontrar a string `J`
```js
assert(!userCheck.test('J'));
```
Your regex should match the string `Jo`
Sua regex deve encontrar a string `Jo`
```js
assert(userCheck.test('Jo'));
```
Your regex should match the string `Oceans11`
Sua regex deve encontrar a string `Oceans11`
```js
assert(userCheck.test('Oceans11'));
```
Your regex should match the string `RegexGuru`
Sua regex deve encontrar a string `RegexGuru`
```js
assert(userCheck.test('RegexGuru'));
```
Your regex should not match the string `007`
Sua regex não deve encontrar a string `007`
```js
assert(!userCheck.test('007'));
```
Your regex should not match the string `9`
Sua regex não deve encontrar a string `9`
```js
assert(!userCheck.test('9'));
```
Your regex should not match the string `A1`
Sua regex não deve encontrar a string `A1`
```js
assert(!userCheck.test('A1'));
```
Your regex should not match the string `BadUs3rnam3`
Sua regex não deve encontrar a string `BadUs3rnam3`
```js
assert(!userCheck.test('BadUs3rnam3'));
```
Your regex should match the string `Z97`
Sua regex deve encontrar a string `Z97`
```js
assert(userCheck.test('Z97'));
```
Your regex should not match the string `c57bT3`
Sua regex não deve encontrar a string `c57bT3`
```js
assert(!userCheck.test('c57bT3'));
```
Your regex should match the string `AB1`
Sua regex deve encontrar a string `AB1`
```js
assert(userCheck.test('AB1'));
```
Your regex should not match the string `J%4`
Sua regex não deve encontrar a string `J%4`
```js
assert(!userCheck.test('J%4'))

View File

@ -1,6 +1,6 @@
---
id: 587d7dbb367417b2b2512baa
title: Reuse Patterns Using Capture Groups
title: Reusando Padrões com Grupos de Captura
challengeType: 1
forumTopicId: 301364
dashedName: reuse-patterns-using-capture-groups
@ -8,13 +8,13 @@ dashedName: reuse-patterns-using-capture-groups
# --description--
Some patterns you search for will occur multiple times in a string. It is wasteful to manually repeat that regex. There is a better way to specify when you have multiple repeat substrings in your string.
Por vezes você procurará padrões que ocorrem várias vezes em uma string. Não faz sentido repetir a regex manualmente. Existe uma forma muito melhor de especificar quando a string possui múltiplas ocorrências do padrão buscado.
You can search for repeat substrings using <dfn>capture groups</dfn>. Parentheses, `(` and `)`, are used to find repeat substrings. You put the regex of the pattern that will repeat in between the parentheses.
Você pode usar <dfn>grupos de captura</dfn> para buscar substrings repetidas. Usamos parênteses (`(` e `)`) para criar grupos de captura. Só precisamos escrever a regex do padrão que se repete dentro deles.
To specify where that repeat string will appear, you use a backslash (`\`) and then a number. This number starts at 1 and increases with each additional capture group you use. An example would be `\1` to match the first group.
E, para especificar que a string capturada pelo grupo se repetirá, você escreve uma barra invertida (`\`) seguida de um número. Esse número começa por 1 e aumenta em um para cada grupo de captura que você usa. Por exemplo, `\1` captura o primeiro grupo.
The example below matches any word that occurs twice separated by a space:
No exemplo abaixo, é capturada qualquer palavra que se repita depois de um espaço:
```js
let repeatStr = "regex regex";
@ -23,65 +23,65 @@ repeatRegex.test(repeatStr);
repeatStr.match(repeatRegex);
```
The `test` call would return `true`, and the `match` call would return `["regex regex", "regex"]`.
Nele, `test` retorna `true` e `match` retorna `["regex regex", "regex"]`.
Using the `.match()` method on a string will return an array with the string it matches, along with its capture group.
O método `.match()` de uma string retorna um array com a string capturada e cada grupo capturado.
# --instructions--
Use capture groups in `reRegex` to match a string that consists of only the same number repeated exactly three times separated by single spaces.
Use grupos de captura na regex `reRegex` para capturar em uma string um número que aparece exatamente três vezes, separados por espaços.
# --hints--
Your regex should use the shorthand character class for digits.
Sua regex deve usar o atalho de classe de caracteres para dígitos.
```js
assert(reRegex.source.match(/\\d/));
```
Your regex should reuse a capture group twice.
Sua regex deve reusar um grupo de captura duas vezes.
```js
assert(reRegex.source.match(/\\1|\\2/g).length >= 2);
```
Your regex should match the string `42 42 42`.
Sua regex deve encontrar a string `42 42 42`.
```js
assert(reRegex.test('42 42 42'));
```
Your regex should match the string `100 100 100`.
Sua regex deve encontrar a string `100 100 100`.
```js
assert(reRegex.test('100 100 100'));
```
Your regex should not match the string `42 42 42 42`.
Sua regex não deve encontrar a string `42 42 42 42`.
```js
assert.equal('42 42 42 42'.match(reRegex.source), null);
```
Your regex should not match the string `42 42`.
Sua regex não deve encontrar a string `42 42`.
```js
assert.equal('42 42'.match(reRegex.source), null);
```
Your regex should not match the string `101 102 103`.
Sua regex não deve encontrar a string `101 102 103`.
```js
assert(!reRegex.test('101 102 103'));
```
Your regex should not match the string `1 2 3`.
Sua regex não deve encontrar a string `1 2 3`.
```js
assert(!reRegex.test('1 2 3'));
```
Your regex should match the string `10 10 10`.
Sua regex deve encontrar a string `10 10 10`.
```js
assert(reRegex.test('10 10 10'));

View File

@ -1,6 +1,6 @@
---
id: 587d7db9367417b2b2512ba7
title: Specify Exact Number of Matches
title: Especificando o Número Exato de Capturas
challengeType: 1
forumTopicId: 301365
dashedName: specify-exact-number-of-matches
@ -8,11 +8,11 @@ dashedName: specify-exact-number-of-matches
# --description--
You can specify the lower and upper number of patterns with quantity specifiers using curly brackets. Sometimes you only want a specific number of matches.
Você pode especificar um número mínimo e um máximo de capturas com chaves. Às vezes, você só quer um número específico de capturas.
To specify a certain number of patterns, just have that one number between the curly brackets.
Para especificar este número, apenas escreva-o dentro das chaves.
For example, to match only the word `hah` with the letter `a` `3` times, your regex would be `/ha{3}h/`.
Por exemplo, você pode escrever a regex `/ha{3}h/` para capturar a letra `a` `3` vezes na string `hah`.
```js
let A4 = "haaaah";
@ -24,49 +24,49 @@ multipleHA.test(A3);
multipleHA.test(A100);
```
In order, the three `test` calls would return `false`, `true`, and `false`.
As três chamadas a `test` acima retornam, na ordem, os valores: `false`, `true` e `false`.
# --instructions--
Change the regex `timRegex` to match the word `Timber` only when it has four letter `m`'s.
Modifique a regex `timRegex` para que capture quatro `m`s na string `Timber`.
# --hints--
Your regex should use curly brackets.
Sua regex deve conter chaves.
```js
assert(timRegex.source.match(/{.*?}/).length > 0);
```
Your regex should not match the string `Timber`
Sua regex não deve encontrar a string `Timber`
```js
timRegex.lastIndex = 0;
assert(!timRegex.test('Timber'));
```
Your regex should not match the string `Timmber`
Sua regex não deve encontrar a string `Timmber`
```js
timRegex.lastIndex = 0;
assert(!timRegex.test('Timmber'));
```
Your regex should not match the string `Timmmber`
Sua regex não deve encontrar a string `Timmmber`
```js
timRegex.lastIndex = 0;
assert(!timRegex.test('Timmmber'));
```
Your regex should match the string `Timmmmber`
Sua regex deve encontrar a string `Timmmmber`
```js
timRegex.lastIndex = 0;
assert(timRegex.test('Timmmmber'));
```
Your regex should not match the string `Timber` with 30 `m`'s in it.
Sua regex não deve encontrar a string `Timber` se nela houver 30 `m`s.
```js
timRegex.lastIndex = 0;

View File

@ -1,6 +1,6 @@
---
id: 587d7db9367417b2b2512ba6
title: Specify Only the Lower Number of Matches
title: Especificando Apenas o Mínimo de Capturas
challengeType: 1
forumTopicId: 301366
dashedName: specify-only-the-lower-number-of-matches
@ -8,11 +8,11 @@ dashedName: specify-only-the-lower-number-of-matches
# --description--
You can specify the lower and upper number of patterns with quantity specifiers using curly brackets. Sometimes you only want to specify the lower number of patterns with no upper limit.
Você pode especificar um número mínimo e um máximo de capturas com chaves. Haverá vezes que você precisará especificar um mínimo mas não um máximo.
To only specify the lower number of patterns, keep the first number followed by a comma.
Para fazer isso, apenas escreva o número seguido de uma vírgula dentro das chaves.
For example, to match only the string `hah` with the letter `a` appearing at least `3` times, your regex would be `/ha{3,}h/`.
Por exemplo, para capturar pelo menos `3` vezes a letra `a` na string `hah` você pode escrever a regex `/ha{3,}h/`.
```js
let A4 = "haaaah";
@ -24,51 +24,51 @@ multipleA.test(A2);
multipleA.test(A100);
```
In order, the three `test` calls would return `true`, `false`, and `true`.
As três chamadas a `test` acima retornam, na ordem, os valores: `true`, `false` e `true`.
# --instructions--
Change the regex `haRegex` to match the word `Hazzah` only when it has four or more letter `z`'s.
Modifique a regex `haRegex` para que capture quatro ou mais `z`s na string `Hazzah`.
# --hints--
Your regex should use curly brackets.
Sua regex deve usar chaves.
```js
assert(haRegex.source.match(/{.*?}/).length > 0);
```
Your regex should not match the string `Hazzah`
Sua regex não deve encontrar a string `Hazzah`
```js
assert(!haRegex.test('Hazzah'));
```
Your regex should not match the string `Hazzzah`
Sua regex não deve encontrar a string `Hazzzah`
```js
assert(!haRegex.test('Hazzzah'));
```
Your regex should match the string `Hazzzzah`
Sua regex deve encontrar a string `Hazzzzah`
```js
assert('Hazzzzah'.match(haRegex)[0].length === 8);
```
Your regex should match the string `Hazzzzzah`
Sua regex deve encontrar a string `Hazzzzzah`
```js
assert('Hazzzzzah'.match(haRegex)[0].length === 9);
```
Your regex should match the string `Hazzzzzzah`
Sua regex deve encontrar a string `Hazzzzzzah`
```js
assert('Hazzzzzzah'.match(haRegex)[0].length === 10);
```
Your regex should match the string `Hazzah` with 30 `z`'s in it.
Sua regex deve capturar 30 `z`s, se presentes, na string `Hazzah`.
```js
assert('Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah'.match(haRegex)[0].length === 34);

View File

@ -1,6 +1,6 @@
---
id: 587d7db9367417b2b2512ba5
title: Specify Upper and Lower Number of Matches
title: Especificando o Número de Capturas
challengeType: 1
forumTopicId: 301367
dashedName: specify-upper-and-lower-number-of-matches
@ -8,11 +8,11 @@ dashedName: specify-upper-and-lower-number-of-matches
# --description--
Recall that you use the plus sign `+` to look for one or more characters and the asterisk `*` to look for zero or more characters. These are convenient but sometimes you want to match a certain range of patterns.
Lembre-se que você pode usar o sinal de `+` para procurar por uma ou mais ocorrências e o asterisco `*` para procurar por zero ou mais ocorrências. Eles são convenientes, mas às vezes você precisa capturar um número exato de caracteres.
You can specify the lower and upper number of patterns with <dfn>quantity specifiers</dfn>. Quantity specifiers are used with curly brackets (`{` and `}`). You put two numbers between the curly brackets - for the lower and upper number of patterns.
Você pode especificar um número mínimo e um máximo de capturas com <dfn>especificadores de quantidade</dfn>. Para usar especificadores de quantidade, usa-se chaves: `{` e `}`. Você pode especificar os dois números dentro delas para restringir as capturas.
For example, to match only the letter `a` appearing between `3` and `5` times in the string `ah`, your regex would be `/a{3,5}h/`.
Por exemplo, se você quiser encontrar a letra `a` de `3` a `5` vezes na string `ah`, você pode escrever a regex `/a{3,5}h/`.
```js
let A4 = "aaaah";
@ -22,51 +22,51 @@ multipleA.test(A4);
multipleA.test(A2);
```
The first `test` call would return `true`, while the second would return `false`.
A primeira chamada a `test` retorna `true` enquanto a segunda retorna `false`.
# --instructions--
Change the regex `ohRegex` to match the entire phrase `Oh no` only when it has `3` to `6` letter `h`'s.
Altere a regex `ohRegex` para que capture a frase `Oh no`, mas apenas quando nela houver de `3` a `6` letras `h`'s.
# --hints--
Your regex should use curly brackets.
Sua regex deve usar chaves.
```js
assert(ohRegex.source.match(/{.*?}/).length > 0);
```
Your regex should not match the string `Ohh no`
Sua regex não deve encontrar a string `Ohh no`
```js
assert(!ohRegex.test('Ohh no'));
```
Your regex should match the string `Ohhh no`
Sua regex deve encontrar a string `Ohhh no`
```js
assert('Ohhh no'.match(ohRegex)[0].length === 7);
```
Your regex should match the string `Ohhhh no`
Sua regex deve encontrar a string `Ohhhh no`
```js
assert('Ohhhh no'.match(ohRegex)[0].length === 8);
```
Your regex should match the string `Ohhhhh no`
Sua regex deve encontrar a string `Ohhhhh no`
```js
assert('Ohhhhh no'.match(ohRegex)[0].length === 9);
```
Your regex should match the string `Ohhhhhh no`
Sua regex deve encontrar a string `Ohhhhhh no`
```js
assert('Ohhhhhh no'.match(ohRegex)[0].length === 10);
```
Your regex should not match the string `Ohhhhhhh no`
Sua regex não deve encontrar a string `Ohhhhhhh no`
```js
assert(!ohRegex.test('Ohhhhhhh no'));

View File

@ -1,6 +1,6 @@
---
id: 587d7dbb367417b2b2512bab
title: Use Capture Groups to Search and Replace
title: Use Grupos de Captura para Buscar e Substituir
challengeType: 1
forumTopicId: 301368
dashedName: use-capture-groups-to-search-and-replace
@ -8,9 +8,9 @@ dashedName: use-capture-groups-to-search-and-replace
# --description--
Searching is useful. However, you can make searching even more powerful when it also changes (or replaces) the text you match.
Buscar texto é útil. É ainda mais útil quando você consegue modificar (ou substituir) o texto que você busca.
You can search and replace text in a string using `.replace()` on a string. The inputs for `.replace()` is first the regex pattern you want to search for. The second parameter is the string to replace the match or a function to do something.
Você pode buscar e substituir texto em uma string usando o método `.replace()`. O primeiro parâmetro do `.replace()` é o padrão regex que você quer procurar. O segundo parâmetro é a string que substituirá o resultado da busca ou uma função que fará algo com ele.
```js
let wrongText = "The sky is silver.";
@ -18,47 +18,47 @@ let silverRegex = /silver/;
wrongText.replace(silverRegex, "blue");
```
The `replace` call would return the string `The sky is blue.`.
A chamada a `replace` aqui retorna a string `The sky is blue.`.
You can also access capture groups in the replacement string with dollar signs (`$`).
Você também pode acessar grupos de captura na string de substituição usando o cifrão (`$`).
```js
"Code Camp".replace(/(\w+)\s(\w+)/, '$2 $1');
```
The `replace` call would return the string `Camp Code`.
A chamada a `replace` aqui retorna a string `Camp Code`.
# --instructions--
Write a regex `fixRegex` using three capture groups that will search for each word in the string `one two three`. Then update the `replaceText` variable to replace `one two three` with the string `three two one` and assign the result to the `result` variable. Make sure you are utilizing capture groups in the replacement string using the dollar sign (`$`) syntax.
Escreva uma regex, `fixRegex`, que usa três grupos de captura para procurar cada palavra na string `one two three`. Depois atualize a variável `replaceText` para trocar de `one two three` para `three two one` e atribuir o resultado à variável `result`. Certifique-se de estar utilizando grupos de captura na string de substituição usando o cifrão (`$`).
# --hints--
You should use `.replace()` to search and replace.
Você deve usar `.replace()` para buscar e substituir.
```js
assert(code.match(/\.replace\(.*\)/));
```
Your regex should change the string `one two three` to the string `three two one`
Sua regex deve mudar a string `one two three` para `three two one`
```js
assert(result === 'three two one');
```
You should not change the last line.
Você não deve alterar a última linha.
```js
assert(code.match(/result\s*=\s*str\.replace\(.*?\)/));
```
`fixRegex` should use at least three capture groups.
`fixRegex` deve usar pelo menos três grupos de captura.
```js
assert(new RegExp(fixRegex.source + '|').exec('').length - 1 >= 3);
```
`replaceText` should use parenthesized submatch string(s) (i.e. the nth parenthesized submatch string, $n, corresponds to the nth capture group).
`replaceText` deve usar os grupos de captura por via da sintaxe $n onde n é o n-ésimo grupo capturado.
```js
{

View File

@ -1,6 +1,6 @@
---
id: 587d7db3367417b2b2512b8e
title: Using the Test Method
title: Usando o Método Test
challengeType: 1
forumTopicId: 301369
dashedName: using-the-test-method
@ -8,11 +8,11 @@ dashedName: using-the-test-method
# --description--
Regular expressions are used in programming languages to match parts of strings. You create patterns to help you do that matching.
Expressões regulares são usadas em linguagens de programação para encontrar e extrair partes de strings. Cria-se padrões que ajudam a encontrar tais partes.
If you want to find the word `the` in the string `The dog chased the cat`, you could use the following regular expression: `/the/`. Notice that quote marks are not required within the regular expression.
Se você quiser encontrar a palavra `the` na string `The dog chased the cat`, você poderia usar a seguinte expressão regular: `/the/`. Note que aspas não são necessárias ao redor da expressão regular.
JavaScript has multiple ways to use regexes. One way to test a regex is using the `.test()` method. The `.test()` method takes the regex, applies it to a string (which is placed inside the parentheses), and returns `true` or `false` if your pattern finds something or not.
O JavaScript oferece múltiplas maneiras de usar <dfn>regexes</dfn>. Uma dessas maneiras é com o método `.test()`. O método `.test()` aplica a regex à string dentro dos parênteses e retorna `true` caso encontre o padrão ou `false` caso contrário.
```js
let testStr = "freeCodeCamp";
@ -20,21 +20,21 @@ let testRegex = /Code/;
testRegex.test(testStr);
```
The `test` method here returns `true`.
O método `test` retorna `true` aqui.
# --instructions--
Apply the regex `myRegex` on the string `myString` using the `.test()` method.
Aplique a regex `myRegex` na string `myString` usando o método `.test()`.
# --hints--
You should use `.test()` to test the regex.
Você deve usar `.test()` para testar a regex.
```js
assert(code.match(/myRegex.test\(\s*myString\s*\)/));
```
Your result should return `true`.
O resultado deve ser `true`.
```js
assert(result === true);