2017-11-14 22:36:45 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
function findNames(text, users) {
|
|
|
|
const result = [];
|
2017-11-30 12:16:11 +00:00
|
|
|
let index = -1;
|
|
|
|
|
2017-11-14 22:36:45 +00:00
|
|
|
users.forEach((nick) => {
|
2017-11-30 12:16:11 +00:00
|
|
|
index = text.indexOf(nick, ++index);
|
2017-11-14 22:36:45 +00:00
|
|
|
result.push({
|
|
|
|
start: index,
|
|
|
|
end: index + nick.length,
|
|
|
|
nick: nick,
|
|
|
|
});
|
|
|
|
});
|
2017-11-30 12:16:11 +00:00
|
|
|
|
2017-11-14 22:36:45 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = findNames;
|