1const regex = /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/gm;
2const str = `http://www.sample.com
3https://www.sample.com
4http://www.sample.com/xyz
5www.sample.com
6www.sample.com/xyz/#/xyz
7sample.com
8www.sample.com
9mofiz.com
10kolim.com
11www.murikhao.www.sample.com
12http://murihao.www.sample.com
13http://www.sample.com/xyz?abc=dkd&p=q&c=2
14www.sample.gov.bd
15www.sample.com.en
16www.sample.vu
17
18
19`;
20let m;
21
22while ((m = regex.exec(str)) !== null) {
23
24 if (m.index === regex.lastIndex) {
25 regex.lastIndex++;
26 }
27 console.log("matched :"+m[0]);
28}