const regex = /(http[s]?:\/\/)?(www.)?(11st|auction|bj\.afreecatv|blog\.naver|blog\.daum|cafe\.daum|cafe\.naver|smartstore\.naver|storefarm\.naver|partner\.booking.naver\.com|partner\.booking\=.naver|shop\.naver\.com|gmarket|go\.kr).*/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(http[s]?:\\\/\\\/)?(www.)?(11st|auction|bj\\.afreecatv|blog\\.naver|blog\\.daum|cafe\\.daum|cafe\\.naver|smartstore\\.naver|storefarm\\.naver|partner\\.booking.naver\\.com|partner\\.booking\\=.naver|shop\\.naver\\.com|gmarket|go\\.kr).*', 'gm')
const str = `http://11st.co.kr
http://www.11st.co.kr
http://auction.co.kr
http://blog.naver.com/wef
http://blog.daum.net/wef
http://bj.afreecatv.com/wef
http://cafe.daum.net
http://cafe.naver.com/
http://smartstore.naver.com
http://smartstore.naver.com/wef
storefarm.naver.com
http://partner.booking.naver.com/bizes
http://shop.naver.com/starkrobotics
http://sell.storefarm.naver.com
https://www.rndia.or.kr/
http://m.hakjum.com/
itskorea.kr
minishop.gmarket.co.kr
hrd.keia.kr
www.dsf.go.kr`;
// 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