Need help with a regular experssion.

Discussion in 'PHP' started by JackIT, Mar 9, 2009.

  1. #1
    I have this piece of code:

    
    if (preg_match('/(http(s?):\/\/)(?!((www[1-5]?|imgs)\.)?somesite\.com(?!\/pan\/)($|\/))/i', $rightlink))
    		{
    			$rightlink = 'http://www.somesite.com/out.php?l=' . urlencode($rightlink);
    		}
    
    PHP:
    I need the reg ex written so that the conditional is false if $rightlink contains the following domains:
    thatsite.com
    othersite.com

    Thanks in advance!
     
    JackIT, Mar 9, 2009 IP
  2. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    You can use parse_url() and compare the hostname for the parsed URL against the hostnames you want to exclude.
     
    nabil_kadimi, Mar 10, 2009 IP
  3. usadesi

    usadesi Peon

    Messages:
    296
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi i want to learn php.please send me the which is best site.
     
    usadesi, Mar 11, 2009 IP
  4. pipes

    pipes Prominent Member

    Messages:
    12,766
    Likes Received:
    958
    Best Answers:
    0
    Trophy Points:
    360
    #4
    pipes, May 2, 2009 IP