ereg_replace with regular expression

Discussion in 'PHP' started by awat, May 20, 2008.

  1. #1
    I try to replace my content. I use ereg_replace how should I do
    
    
    <?php
      $content = 'Some men keep trying and never get anywhere with dating';
      $content = ereg_replace('[color=red]x[/color]','',$content); // I want cut before 'trying'
      
      $content = ereg_replace('[color=blue]y[/color]','',$content);  //I want cunt after 'anywhere'
      
      echo $content;  // result = 'trying and never get anywhere'
    ?>
    
    Code (markup):
    what regular expression that use in x and y
     
    awat, May 20, 2008 IP
  2. anwaraa

    anwaraa Active Member

    Messages:
    167
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    90
    Digital Goods:
    2
    #2
    what are you trying to achieve? Are you always going to cut the same string for result and will you always use the same string to start? Or if strings going to be different, is there a set pattern? Maybe if you give me more info, I can help.
     
    anwaraa, May 23, 2008 IP