[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] - Regex help



On 10/18/2007 08:05 AM, Andrea Ganduglia wrote:
<?php
    $str = 'I\'m a text: =match1 =match2=match3=match4 =nomatch{}
=match5=match6';
[...]

Use grep to remove the unwanted match like so (watch out for wrapping):

<?php
$str = 'I\'m a text: =match1 =match2=match3=match4 =nomatch{} =match5=match6';
    $rex = "/=[A-z0-9]+/";
    $N = preg_match_all($rex,$str,$out);
    $out[0] = preg_grep("/nomatch/",$out[0],PREG_GREP_INVERT);
    header("Content-Type: text/plain");

    print $N." $str\n";
    print_r($out);
?>






Reply to: