Tried negative look ahead but that doesnt seem to help
/^(?!www).(https:\/\/[^\s$\<]+)/g)
const regex = /(?!www).(https:\\/\\/[^\\s$\\<]+)/g; [ 'https://google.fr', 'https://www.google.fr', 'www.google.fr', 'google.fr', ].forEach((x) => { console.log(regex.test(x)); });
You can use this since it's for validating links also :
const regex = /https?:\\/\\/(?!www\\.)[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)/; [ 'https://google.fr', 'https://www.google.fr', 'www.google.fr', 'google.fr', ].forEach((x) => { console.log(regex.test(x)); });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.