Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Regex for URL

Regex for URL

Scheduled Pinned Locked Moved ASP.NET
javascriptcomregexhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brij
    wrote on last edited by
    #1

    Hi Can anyone please tell me the regex for URL in javascript.Actully from Googling the regex i got,doesn't solve my problem,because if i write http://www.google.com or http://www.google both is passed i want if user enters www the it should check at least two'.' else one will be enough. Thanks in advance

    I 1 Reply Last reply
    0
    • B Brij

      Hi Can anyone please tell me the regex for URL in javascript.Actully from Googling the regex i got,doesn't solve my problem,because if i write http://www.google.com or http://www.google both is passed i want if user enters www the it should check at least two'.' else one will be enough. Thanks in advance

      I Offline
      I Offline
      Imran Khan Pathan
      wrote on last edited by
      #2

      Brij wrote:

      i want if user enters www the it should check at least two'.' else one will be enough.

      try this /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ or Regular Express String http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?

      please don't forget to vote on the post that helped you.

      B 1 Reply Last reply
      0
      • I Imran Khan Pathan

        Brij wrote:

        i want if user enters www the it should check at least two'.' else one will be enough.

        try this /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ or Regular Express String http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?

        please don't forget to vote on the post that helped you.

        B Offline
        B Offline
        Brij
        wrote on last edited by
        #3

        Hi It doesn't solve my solve.it pass "http://www.home".My issue is,can we make "www" as optional,means http://www.google.com and http://google.com shold pass but http://www.google or http://www.gooogle. should not.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups