preg_replace

Discussion in 'PHP' started by buldozerceto, Dec 26, 2007.

  1. #1
    I have problems with preg_replace

    here is the code
    $thing='bla |block| text here |/block| text here';
    echo preg_replace('/\|block\|.*[^\/b].*\|\/block\|/i','',$thing);
    //prints bla |block| text here |/block| text here
    Code (markup):
    it prints the same means no match found
    I want to replace |block|anything|block| with ''
    Any help pls?
     
    buldozerceto, Dec 26, 2007 IP
  2. x11joex11

    x11joex11 Peon

    Messages:
    106
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    (nevermind)
     
    x11joex11, Dec 26, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    
    '~\|block\|.*?\|block\|~si'
    
    PHP:
    Give this a try.
     
    nico_swd, Dec 27, 2007 IP