regex to detect whole string in php

Discussion in 'PHP' started by ironmankho, Sep 15, 2011.

  1. #1
    can anyone php expert help me to detect this [$string=\n\n(\n\n52556\n\n)] in php via Regex

    because i want to remvoe form this line

    now : Domino Developer \n\n(\n\n52338\n\n) Reston
    my requirement : Domino Developer Reston


    $string=\n\n(\n\n52556\n\n)
     
    Solved! View solution.
    ironmankho, Sep 15, 2011 IP
  2. #2
    This is just a quick way, that I would use
    
    <?php
    
    $now = "Domino Developer \n\n(\n\n52338\n\n) Reston";
    
    // lets remove what you dont't want \n\n(\n\n52338\n\n) leaving letters and spaces only
    $now = preg_replace("#[^A-Za-z ]#", "", $now); 
    
    // opps we ended up with 2 spaces before "Reston", lets change that to 1 space
    $my_requirements = str_replace('  ',' ',$now);
    
    // All Done, this is what you wanted
    echo $my_requirements; // Domino Developer Reston
    
    ?>
    
    PHP:
     
    Last edited: Sep 15, 2011
    MyVodaFone, Sep 15, 2011 IP
  3. ironmankho

    ironmankho Active Member

    Messages:
    393
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    Thanks for this ... that is my requirement..bundle of thanks
     
    ironmankho, Sep 16, 2011 IP