JSFiddle - React, Tailwind, and code Playground
by Londonzap
HTML
<div class="text">
http://2gis.ru
http://www.yp.ru
http://www.yell.ru
http://www.ypag.ru
http://www.e-adres.ru
http://infolo.ru
http://globalmcom.com
</div>
JavaScript
let text = document.querySelector('.text');
let regexp = /(https?:\/\/\S+)$/gm;
let newText, result;
result = text.innerHTML.match(regexp) || [];
if (result.length) {
newText = '';
result.forEach(function(item) {
newText += item + '<br>';
});
text.innerHTML = newText.slice(0, -4);
}