lenamtl
asked on
Need some help with regex
Hi,
I have this php regex to validate url, this is working fine but it's allows
these formats that I want to prevent ww.test.org and w.test.org
So is this possible to catch these cases with or without http https, without blocking others cases?
This should accept with or without http, https, with or without www
Some accepted formats
www.code.org
http://code.longtd
https://code.uk.co
code.com
http://code.com
Thanks
I have this php regex to validate url, this is working fine but it's allows
these formats that I want to prevent ww.test.org and w.test.org
So is this possible to catch these cases with or without http https, without blocking others cases?
This should accept with or without http, https, with or without www
Some accepted formats
www.code.org
http://code.longtd
https://code.uk.co
code.com
http://code.com
^(((http(?:s)?\:\/\/)|www\.)?[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*\.[a-zA-Z]{2,6}(?:\/?|(?:\/[\w\-]+)*)(?:\/?|\/\w+((\.[a-zA-Z]{2,4})?)(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
(?!w+\.)
since you would only 3 w and not any other number of w(1,2,4,...)