56 lines
3.1 KiB
Markdown
56 lines
3.1 KiB
Markdown
|
---
|
|||
|
id: 587d7db5367417b2b2512b96
|
|||
|
title: Match Letters of the Alphabet
|
|||
|
challengeType: 1
|
|||
|
videoUrl: ''
|
|||
|
localeTitle: Матч-буквы алфавита
|
|||
|
---
|
|||
|
|
|||
|
## Description
|
|||
|
<section id="description"> Вы видели, как вы можете использовать <code>character sets</code> чтобы указать группу символов для соответствия, но это очень много, когда вам нужно сопоставить большой диапазон символов (например, каждую букву в алфавите). К счастью, есть встроенная функция, которая делает это коротким и простым. Внутри <code>character set</code> вы можете определить диапазон символов в соответствии с символом <code>hyphen</code> : <code>-</code> . Например, чтобы соответствовать строчным буквам от <code>a</code> до <code>e</code> вы должны использовать <code>[ae]</code> . <blockquote> let catStr = "cat"; <br> let batStr = "bat"; <br> пусть matStr = "мат"; <br> пусть bgRegex = / [ae] at /; <br> catStr.match (bgRegex); // Возвращает ["cat"] <br> batStr.match (bgRegex); // Возвращает ["bat"] <br> matStr.match (bgRegex); // Возвращает значение null </blockquote></section>
|
|||
|
|
|||
|
## Instructions
|
|||
|
<section id="instructions"> Сопоставьте все буквы в строке <code>quoteSample</code> . <strong>Заметка</strong> <br> Обязательно сопоставляйте <strong>буквы</strong> верхнего и нижнего регистра <strong><strong>.</strong></strong> </section>
|
|||
|
|
|||
|
## Tests
|
|||
|
<section id='tests'>
|
|||
|
|
|||
|
```yml
|
|||
|
tests:
|
|||
|
- text: Ваше регулярное выражение <code>alphabetRegex</code> должно соответствовать 35 пунктам.
|
|||
|
testString: 'assert(result.length == 35, "Your regex <code>alphabetRegex</code> should match 35 items.");'
|
|||
|
- text: Ваша регулярное выражение <code>alphabetRegex</code> следует использовать глобальный флаг.
|
|||
|
testString: 'assert(alphabetRegex.flags.match(/g/).length == 1, "Your regex <code>alphabetRegex</code> should use the global flag.");'
|
|||
|
- text: Ваша регулярное выражение <code>alphabetRegex</code> следует использовать регистрозависимости флаг.
|
|||
|
testString: 'assert(alphabetRegex.flags.match(/i/).length == 1, "Your regex <code>alphabetRegex</code> should use the case insensitive flag.");'
|
|||
|
|
|||
|
```
|
|||
|
|
|||
|
</section>
|
|||
|
|
|||
|
## Challenge Seed
|
|||
|
<section id='challengeSeed'>
|
|||
|
|
|||
|
<div id='js-seed'>
|
|||
|
|
|||
|
```js
|
|||
|
let quoteSample = "The quick brown fox jumps over the lazy dog.";
|
|||
|
let alphabetRegex = /change/; // Change this line
|
|||
|
let result = alphabetRegex; // Change this line
|
|||
|
|
|||
|
```
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</section>
|
|||
|
|
|||
|
## Solution
|
|||
|
<section id='solution'>
|
|||
|
|
|||
|
```js
|
|||
|
// solution required
|
|||
|
```
|
|||
|
</section>
|