delete link using preg_replace ?

Discussion in 'PHP' started by davebrwn, Feb 4, 2010.

  1. #1
    Hello

    I would like to know how to delete links and may not appear click able on a string using preg_replace, I have a issue with regular expressions? Also how to delete images 'being click able or not' ?

    Thank you
     
    davebrwn, Feb 4, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Could you be a bit more specific and provide some code. The question is vague to say the least
     
    JAY6390, Feb 4, 2010 IP
  3. beacon

    beacon Peon

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    delete all links+anchors
    $s='some html ....... ';
    $s = preg_replace('~<a [^>]+>[^<]+</a>~isU', '', $s);

    only a tags:
    $s='some html ....... ';
    $s = preg_replace('~<a [^>]+>([^<]+)</a>~isU', '\\1', $s);
     
    Last edited: Feb 4, 2010
    beacon, Feb 4, 2010 IP
  4. davebrwn

    davebrwn Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks beacon , That worked :)
     
    davebrwn, Feb 4, 2010 IP