preg_replace for (...), pattern??

Discussion in 'PHP' started by 123GoToAndPlay, Apr 13, 2009.

  1. #1
    Hi there,

    Again stuck with preg_replace. I am trying to remove/cut/skip the first time
    (asdf), appears. Need this for a mysql query
    
    $content = preg_replace('#\(*\),#', '', $content, 1);
    
    Code (markup):
    regards
     
    123GoToAndPlay, Apr 13, 2009 IP
  2. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $content = preg_replace('#\(.*?\),#', '', $content, 1);
    Code (markup):
     
    SmallPotatoes, Apr 13, 2009 IP
  3. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #3
    Hi,

    another suggestion:
    $content = preg_replace('#\([^\)]*\),#','',$content,1);
    PHP:
    pp: Maybe you should better use REGEXP in your query.

    Regards.
     
    koko5, Apr 13, 2009 IP
  4. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hi smallpotatoes,

    oops,

    koko5 solution worked like a charm, tx.
     
    123GoToAndPlay, Apr 13, 2009 IP