How to remove word starting with xxx from value?

Discussion in 'PHP' started by abdobasha2004, Sep 14, 2009.

  1. #1
    I have a value named threadinfo['preview'], it is in vbulletin script
    I want to make a plugin, php code that :
    do not allow word starting with http://, so that no url appear in the value threadinfo['preview']

    so that for example the value = "http://forums.digitalpoint.com/images/smilies/tongue.gif hi I would like to introduce my self to all, I am new at PHP..."

    looks like:"hi I would like to introduce my self to all, I am new at PHP..."

    I am really new at PHP and any help would be appreciated :eek:
     
    abdobasha2004, Sep 14, 2009 IP
  2. Deus Ex

    Deus Ex Peon

    Messages:
    531
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    make it so that the threadinfo preview command is used with javascript attached and ensure that the callback / result given for the command being taken shows only the title of the thread rather than the url and title or something of that area.

    It's all about getting it to be %threadtitle, for example
     
    Deus Ex, Sep 14, 2009 IP
  3. abdobasha2004

    abdobasha2004 Well-Known Member

    Messages:
    1,117
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    160
    #3
    ok, but this is not what i am asking about, if I wanted the thread title I ll just use its predefined value, threadinfo['title']
    how ever I want the first words of the post, which are found in threadinfo['preview'] BUT skip any URL

    thanks for the try
     
    abdobasha2004, Sep 14, 2009 IP
  4. jeff_oneil

    jeff_oneil Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Are you absolutely sure that each value will start with a url?

    value = "http://forums.digitalpoint.com/images/smilies/tongue.gif hi I would like to introduce my self to all, I am new at PHP..."

    If so you could use a preg query and say the following:

    capture the following http://[any character except the space] [<- capture here ->]

    The preg query for such a task is as follows:

    .*?http://[^ ]*(.*?)"

    Let me know if that helps.
     
    jeff_oneil, Sep 14, 2009 IP
  5. abdobasha2004

    abdobasha2004 Well-Known Member

    Messages:
    1,117
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    160
    #5
    thanks jeff
    I think you are so close to the answer I need
    however, not all threadinfo['preview'] start with url !

    as I said I am very new at PHP
    so if I have a plugin in this value
    how should it look like?
     
    abdobasha2004, Sep 14, 2009 IP
  6. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #6
    Try:
    This **should look for all URLS in a string and get rid of them.
    
    $string = preg_replace("/(http:\/\/[^\s]+)/", "", $string);
    
    PHP:
     
    dweebsonduty, Sep 15, 2009 IP
  7. abdobasha2004

    abdobasha2004 Well-Known Member

    Messages:
    1,117
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    160
    #7
    thaks alot
    it did not work
    any idea how to use it on vbulletin
    thanks a lot again
     
    abdobasha2004, Sep 15, 2009 IP