Have a situation where I have a string with multiple links strings as below. I need to replace the link with actual links eg : <a href=”http://www.testing.com” target=_blank>http://www.asdfasd.com</a>
Example 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
I am using the below function to get indexes of everywhere that the 'http' occurs but wanted to know if there is an easier way.
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;
}