const regex = /^http[s]?:\/\/[^\/]*\.[a-z]+\/?$/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^http[s]?:\\\/\\\/[^\\\/]*\\.[a-z]+\\\/?$', 'gm')
const str = `https://www.feetrader.com/jobPostings
http://www.bienesonline.es/asociarse/
http://www.bienesonline.mx/asociarse/
http://www.bienesonline.cl/asociarse/
http://www.bienesonline.co/asociarse/
http://www.geralimoveis.com.br/produtos/
http://usa.bienesonline.com/asociarse/
http://www.informatik.uni-linz.ac.at/jobs/
http://informatik.jku.at/jobs/
https://2012.nosql-matters.org/bcn/
https://www.mapmeo.com/partner
http://www.revistapremier.com.br/contemporanea/
https://zippyapp.com/business
http://graph.storn.es/
http://www.volcanicinternet.com/portfolio/
http://imobsync.com.br/
http://trovit.com.isdownorblocked.com/
http://infoday.hoyu.edu.hk/test/
http://2016.desymfony.com/patrocinadores
https://osclass.com/en/
https://imobtic.com.br/
http://www.trovit.at-s.seohighscore.com/
https://dom.yuga.ru/sites/
https://www.kadaza.com/classifieds
http://www.oxleyrobert.com/
http://blog.trovit.de/
http://job.trovit.at/
https://www.sistemarsi.com/privacy
https://www.docjobs.at/
https://www.bienesonline.com.ar/asociarse/`;
// 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