Thread: Validate url

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    7
    Rep Power
    0

    Validate url


    hello all,
    help with this
    regular expression to accept these inputs example1.com/???? | www.example2.it/??? | http://example3.net/?????? should not accept anything else

    Code:
    /^(http|https?):\/\/+(www.)?[example|example1].[com|net|it|bz]{2,3}\/[a-z0-9-A-Z]?$/;
    I tested this but does not work
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,959
    Rep Power
    9397
    [] is a character set. It means that every individual character inside is allowable. When you say [example] you're really saying "either an a, e, l, m, p, or x".
    If you want to group a set of alternatives then use ()s like you did at the very beginning.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    7
    Rep Power
    0
    Originally Posted by requinix
    [] is a character set. It means that every individual character inside is allowable. When you say [example] you're really saying "either an a, e, l, m, p, or x".
    If you want to group a set of alternatives then use ()s like you did at the very beginning.
    Code:
    /^.*(example.com|example2.com|example.it).*$/
    it work, thank you

IMN logo majestic logo threadwatch logo seochat tools logo