Keep formatting but paste without hyperlinks

Discussion in 'HTML & Website Design' started by dastuff, Aug 4, 2006.

  1. #1
    Hi all,

    I'm looking for some sort of "paste special" that keeps the formatting such as <h3>, <b> , whatever, but dehyperlinks all the links... I want the text to stay there but don't want it to point to the hyperlink anymore.

    The reason is because I want to copy a couple wiki articles for certain explanations on my website, but I don't want all the broken wiki links going with it... I'd like to keep the syntax though.

    Don't worry though I am citing and linking back to the wiki article at the bottom. :) Don't want to steal someone else's work.

    Thanks,

    Dastuff

    ps. I notice that when I paste into wordpad it takes out the hyperlinks.. but it also loses the formatting :(
     
    dastuff, Aug 4, 2006 IP
  2. danielbruzual

    danielbruzual Active Member

    Messages:
    906
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    70
    #2
    You should be able to do it in php with preg_replace(). You should consider asking a programmer since it is not very easy to write the patterns.
     
    danielbruzual, Aug 4, 2006 IP
  3. dastuff

    dastuff Peon

    Messages:
    475
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What is a preg_replace?

    Does anyone know of any other programs that are able to do this or is it basically as a programmer? The problem with a preg_replace I would think is I don't want to get rid fo all the links on the page but rather just the wiki ones... Any additional help would be appreciated.

    Thanks.
     
    dastuff, Aug 4, 2006 IP
  4. danielbruzual

    danielbruzual Active Member

    Messages:
    906
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    70
    #4
    preg_replace is a php function that allows you to replace text that matches a predefined pattern in a string.

    I am not a programmer but the best I could come up with is to come up with some function (in php) that does this:

    Check all the text (the string you parse to the function) and see if a link is internal or if it belongs to the wiki.
    If it is internal or links to a page other than the wiki's, leave it as is.
    If it links to the wiki delete the link and leave only the anchor(using regular expressions)
    Return modified text.
     
    danielbruzual, Aug 5, 2006 IP