caret для поиска шаблонов в начале строк. Существует также способ поиска шаблонов в конце строк. Вы можете искать конец строк, используя dollar sign $ в конце регулярного выражения. пусть TheEnding = «Это бесконечная история»;
let storyRegex = / story $ /;
storyRegex.test (theEnding);
// Возвращает true
let noEnding = "Иногда история должна закончиться";
storyRegex.test (noEnding);
// Возвращает false
$ ), чтобы соответствовать строке "caboose" в конце строки caboose . "caboose" with the dollar sign $ anchor in your regex.");'
- text: ''
testString: 'assert(lastRegex.flags == "", "Your regex should not use any flags.");'
- text: Вы должны соответствовать "caboose" в конце строки "The last car on a train is the caboose"
testString: 'assert(lastRegex.test("The last car on a train is the caboose"), "You should match "caboose" at the end of the string "The last car on a train is the caboose"");'
```