#1
  1. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Nov 2001
    Location
    North West UK
    Posts
    1,147
    Rep Power
    396

    Block doesn't contain sequence?


    I'm trying to extract a list of "entries" from between pairs of tags in a string, where the entries don't contain a particular value.

    The following will return all of entries between the A+ and -A tags, except where the entry contains a numeric 5 among its digits.
    PHP Code:
    $test '12 A+ 1234 -A 34 A+ 3456 -A 56 A+ 5678 -A 78';

    preg_match_all('/A\+([^5]*)\-A/U'$test$matchesPREG_SET_ORDER);
    echo 
    '<pre>';
    print_r($matches);
    echo 
    '</pre><br />'
    So far, so good.

    However, what I need is for numbers containing a specific sequence of digits to be excluded, rather than just a single digit.
    I've tried modifying ([^5]*) to ([^(45)]*) expecting it to return the 1234 and 5678 values, only excluding the 3456 value; but instead it returns nothing.

    I'm assuming that the (45) is being ORed: treated as "not containing either 4 or 5". How can I modify the regexp to treat this as a sequence of values rather than a series of options?

    Any help with what I'm doing wrong?
    Last edited by Mark Baker; September 22nd, 2009 at 06:44 AM.
    9 out of 10 PHP problems can be resolved by setting
    PHP Code:
    error_reporting(E_ALL);
    ini_set('display_errors'1); 
    php -l <filename> will identify 9 out of the remaining 10 problems
    Remember, the command line is your friend

    Development Projects:
    PHPExcel
    PHPPowerPoint
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Nov 2001
    Location
    North West UK
    Posts
    1,147
    Rep Power
    396
    Solved
    Was actually a part of my solution for this issue
    9 out of 10 PHP problems can be resolved by setting
    PHP Code:
    error_reporting(E_ALL);
    ini_set('display_errors'1); 
    php -l <filename> will identify 9 out of the remaining 10 problems
    Remember, the command line is your friend

    Development Projects:
    PHPExcel
    PHPPowerPoint

IMN logo majestic logo threadwatch logo seochat tools logo