^(https://|http://|ftp://|ftps://)(?!-.)[^\\s/\$.?#].[^\\s]*$ This is a regex to validate URL for protocols http, https, ftp and ftps.