const regex = /((?:http:\/\/+|www\.+|https:\/\/+)(?:\W+|\S+|\s+|.+)(?:\.net+|\.ro+))/mgi;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('((?:http:\\\/\\\/+|www\\.+|https:\\\/\\\/+)(?:\\W+|\\S+|\\s+|.+)(?:\\.net+|\\.ro+))', 'mgi')
const str = `glass shoes door window door glasses. window glasses sunglasses
glass
asdblog
{www.asdblog.iqads.net}
{http://creator.iqads.ro/NESCAFE3in1}
http://twitter.com/share
http://cdn.iqads.ro/photos/tags/11912.png
http://cluj.tecomm.ro/
http://www.godmother.ro
http://www.facebook.com/godmotherBTL
http://twitter.com/share
http://media.iqads.ro/2015/10/rm2hb-cover-400.jpg
http://media.iqads.ro/2015/09/vv-cover-800-cover-400.jpg
http://media.iqads.ro/2015/08/razvan-mitoiu-photo-cover-400.jpg
http://media.iqads.ro/2015/06/dsc7179-cover-400.jpg
http://media.iqads.ro/2015/05/raluca2-cover-400.jpg
http://media.iqads.ro/2015/05/1me-cover-400.jpg
http://cdn.iqads.ro/photos/tags/263355.png
http://cdn.iqads.ro/photos/tags/32786.png
http://cdn.iqads.ro/photos/tags/22703.png
http://cdn.iqads.ro/photos/tags/23589.png
http://cdn.iqads.ro/photos/tags/228683.png
http://cdn.iqads.ro/photos/tags/23696.png
http://cdn.iqads.ro/photos/tags/16968.png
http://cdn.iqads.ro/photos/tags/263192.png
http://www.blueidea.ro
http://www.blueidea.ro`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions