The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



Вариант для распечатки  
Пред. тема | След. тема 
Форум Разговоры, обсуждение новостей
Режим отображения отдельной подветви беседы [ Отслеживать ]

Оглавление

Релиз Firefox 88, opennews (??), 19-Апр-21, (0) [смотреть все]

Сообщения [Сортировка по времени | RSS]


45. "Релиз Firefox 88"  –1 +/
Сообщение от rvs2016 (ok), 19-Апр-21, 20:25 
> В JavaScript для результата выполнения регулярных выражений
> добавлено свойство "indices"

...


let re = /quick\s(brown).+?(jumps)/igd;
let result = re.exec('The Quick Brown Fox Jumps Over The Lazy Dog');

// result.indices[0] === Array [ 4, 25 ]
// result.indices[1] === Array [ 10, 15 ]
// result.indices[2] === Array [ 20, 25 ]

А тут имеется в виду "и так далее" (indices[3], indices[4], ...), если в регулярное выражение натолкать ещё скобок типа (шаблон 3), (шаблон 4), ... ?

Ответить | Правка | Наверх | Cообщить модератору

63. "Релиз Firefox 88"  +/
Сообщение от MDN (?), 19-Апр-21, 21:16 
> indices
> An array where each entry represents a substring match. Each substring match itself is an array where the first entry represents its start index and the second entry its end index.
> The indices array additionally has a groups property which holds an object of all named capturing groups. The keys are the names of the capturing groups and each value is an array with the first item being the start entry and the second entry being the end index of the capturing group. If the regular expression doesn't contain any capturing groups, groups is undefined.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Ответить | Правка | Наверх | Cообщить модератору

68. "Релиз Firefox 88"  –1 +/
Сообщение от rvs2016 (ok), 19-Апр-21, 21:50 
>> indices
>> An array where each entry represents a substring match. Each substring match itself is an array where the first entry represents its start index and the second entry its end index.
>> The indices array additionally has a groups property which holds an object of all named capturing groups. The keys are the names of the capturing groups and each value is an array with the first item being the start entry and the second entry being the end index of the capturing group. If the regular expression doesn't contain any capturing groups, groups is undefined.
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Чё-то там по басурмански понаписали...
Но результат вроде такой, который я и предположил:

Property/Index:
[1], ...[n]

Ответить | Правка | Наверх | Cообщить модератору

Архив | Удалить

Рекомендовать для помещения в FAQ | Индекс форумов | Темы | Пред. тема | След. тема




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру