Dealing with a scenario where a string contains multiple links that need to be replaced with actual HTML links, for example:
<a href=”http://www.testing.com” target=_blank>http://www.asdfasd.com</a>
Sample text:
http://www.testing.com
Simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap https://asdfasdf.com
A function is being used to identify the indexes where 'http' occurs in the string, but exploring if there's a simpler method available.
indexes(comments.Answers, "http");
function indexes(source, find) {
var result = [];
for (var i = 0; i < source.length; ++i) {
// If you want to search case insensitive use
// if (source.substring(i, i + find.length).toLowerCase() == find) {
if (source.substring(i, i + find.length) == find) {
result.push(i);
}
}
console.log("result ", result);
return result;
}