php text box text analysis

Discussion in 'Programming' started by iwantvarun, Feb 13, 2011.

  1. #1
    I am looking for a simple php code to check comments submitted by end use contain any url or not.

    please help
     
    iwantvarun, Feb 13, 2011 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    You need to do a preg match to match a url into given string.

    Following would be of some help..

    
    preg_match_all("#((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)#", $input_text, $matches);
    
    PHP:
     
    mastermunj, Feb 14, 2011 IP
  3. iwantvarun

    iwantvarun Active Member

    Messages:
    200
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    thank you let me check i will get back to you.
     
    iwantvarun, Feb 14, 2011 IP
  4. Scoding

    Scoding Well-Known Member

    Messages:
    1,091
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    155
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    https? could also be http :)
     
    Scoding, Feb 14, 2011 IP
  5. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    The regex will match both, http & https :)
     
    mastermunj, Feb 14, 2011 IP