56 lines
2.6 KiB
Markdown
56 lines
2.6 KiB
Markdown
|
---
|
|||
|
id: 587d7db3367417b2b2512b8f
|
|||
|
title: Match Literal Strings
|
|||
|
challengeType: 1
|
|||
|
videoUrl: ''
|
|||
|
localeTitle: Литературные строки
|
|||
|
---
|
|||
|
|
|||
|
## Description
|
|||
|
<section id="description"> В последнем вызове вы искали слово <code>"Hello"</code> используя регулярное выражение <code>/Hello/</code> . Это регулярное выражение искало буквальное совпадение строки <code>"Hello"</code> . Вот еще один пример поиска литерального соответствия строки <code>"Kevin"</code> : <blockquote> пусть testStr = «Привет, меня зовут Кевин»; <br> пусть testRegex = / Kevin /; <br> testRegex.test (testStr); <br> // Возвращает true </blockquote> Любые другие формы <code>"Kevin"</code> не совпадают. Например, regex <code>/Kevin/</code> не будет соответствовать <code>"kevin"</code> или <code>"KEVIN"</code> . <blockquote> let wrongRegex = / kevin /; <br> wrongRegex.test (testStr); <br> // Возвращает false </blockquote> Будущая задача покажет, как соотнести эти другие формы. </section>
|
|||
|
|
|||
|
## Instructions
|
|||
|
<section id="instructions"> Заполните regex <code>waldoRegex</code> чтобы найти <code>"Waldo"</code> в строке <code>waldoIsHiding</code> с буквальным совпадением. </section>
|
|||
|
|
|||
|
## Tests
|
|||
|
<section id='tests'>
|
|||
|
|
|||
|
```yml
|
|||
|
tests:
|
|||
|
- text: Ваше регулярное выражение <code>waldoRegex</code> должно найти <code>"Waldo"</code>
|
|||
|
testString: 'assert(waldoRegex.test(waldoIsHiding), "Your regex <code>waldoRegex</code> should find <code>"Waldo"</code>");'
|
|||
|
- text: ''
|
|||
|
testString: 'assert(!waldoRegex.test("Somewhere is hiding in this text."), "Your regex <code>waldoRegex</code> should not search for anything else.");'
|
|||
|
- text: Вы должны выполнить буквальное совпадение строк с вашим регулярным выражением.
|
|||
|
testString: 'assert(!/\/.*\/i/.test(code), "You should perform a literal string match with your regex.");'
|
|||
|
|
|||
|
```
|
|||
|
|
|||
|
</section>
|
|||
|
|
|||
|
## Challenge Seed
|
|||
|
<section id='challengeSeed'>
|
|||
|
|
|||
|
<div id='js-seed'>
|
|||
|
|
|||
|
```js
|
|||
|
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
|
|||
|
let waldoRegex = /search/; // Change this line
|
|||
|
let result = waldoRegex.test(waldoIsHiding);
|
|||
|
|
|||
|
```
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</section>
|
|||
|
|
|||
|
## Solution
|
|||
|
<section id='solution'>
|
|||
|
|
|||
|
```js
|
|||
|
// solution required
|
|||
|
```
|
|||
|
</section>
|