0

i am working with jquery and i was wondering what is the best regular expression for web site that will allow the following examples :

i was using this expression but its not working with all the examples .

[A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?
Harpreet Singh
  • 2,545
  • 18
  • 30
  • possible duplicate of [What is the best regular expression to check if a string is a valid URL?](http://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url) – meager Jul 30 '14 at 02:41

3 Answers3

0

Made this one for you:

(https?://)?(www\.)?google.com

You can test it here: http://regexpal.com/

Vennik
  • 555
  • 3
  • 11
0

Try this one

UPDATED to include 'google.com'

^((ht|f)tp(s?)\:\/\/)?(([a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+)+)|localhost)(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?([\d\w\.\/\%\+\-\=\&\?\:\\\"\'\,\|\~\;]*)$
Trevor Hutto
  • 1,922
  • 4
  • 17
  • 27
0

If you only want to verify domains you could try this:

(\w{3,9}:\/\/)?([wW]\.)?([\w\d_%\-:=]+(\.|$|\b)){2,}
Chris
  • 319
  • 3
  • 17