Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

add site url validation regex

const 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;
const str = `http://www.sample.com
https://www.sample.com
http://www.sample.com/xyz
www.sample.com
www.sample.com/xyz/#/xyz
sample.com
www.sample.com
mofiz.com
kolim.com
www.murikhao.www.sample.com
http://murihao.www.sample.com
http://www.sample.com/xyz?abc=dkd&p=q&c=2
www.sample.gov.bd
www.sample.com.en
www.sample.vu


`;
let m;

while ((m = regex.exec(str)) !== null) {

    if (m.index === regex.lastIndex) {
        regex.lastIndex++;
    }
    console.log("matched :"+m[0]);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree 
Javascript :: open websute react native 
Javascript :: js download canvas as png 
Javascript :: dinosaur game 
Javascript :: axios send bearer token 
Javascript :: counterup2.js cdn 
Javascript :: set attribute checked jquery 
Javascript :: text decoration react native 
Javascript :: ajax beforesend 
Javascript :: javascript check for undefined 
Javascript :: how to check if local storage variable exists in javascript 
Javascript :: jquery check if checkbox is checked 
Javascript :: js get initials from name 
Javascript :: get current path nodejs 
Javascript :: javascript confirm yes no 
Javascript :: emmet not working in react nextjs 
Javascript :: invalid host header vue 
Javascript :: python save list to json 
Javascript :: javascript change css float property 
Javascript :: puppeteer headless false 
Javascript :: javascript math.random from list 
Javascript :: jquery set href of link 
Javascript :: JS get random number between 
Javascript :: jquery cdn cloudflare 
Javascript :: jquery get element by class and data attribute 
Javascript :: fetch get authorization header 
Javascript :: beautify json python 
Javascript :: js wait sleep 
Javascript :: npm check updates 
Javascript :: req.body is undefined 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =