Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

url regex without http://www [closed]

Tags:

regex

url

i need a url regex which validates the url string without http://www. or https://www.

any ideas?

like image 729
input Avatar asked Jul 22 '10 14:07

input


People also ask

How do you match a URL in RegEx?

@:%_\+~#= , to match the domain/sub domain name. In this solution query string parameters are also taken care. If you are not using RegEx , then from the expression replace \\ by \ . Hope this helps.

What is RegEx URL?

URL regular expressions can be used to verify if a string has a valid URL format as well as to extract an URL from a string.

What are RegEx patterns?

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.


1 Answers

It would probably be a good idea to keep the www's intact in order to preserve the sub-domain. A regex pattern like this:

^([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+.*)$

would match a URL that is not prefixed by a protocol (http://,https://,ftp://,etc).

like image 147
sigint Avatar answered Oct 03 '22 23:10

sigint