[PHP-DEV] backrefs in ereg() and preg_match() (was Bug #3014) From: Chad Miller (cmiller <email protected>)
Date: 12/20/99

Hi, all. I'll be on the dev list, soon.

Consider this code, under 4.0b3:

#! php -q
<?php
$address = "AB:BC:CD:DE:EF:AF";
if (preg_match("/^[A-F]{2}([-:;,]?)([A-F]{2}\\1){4}[A-F]{2}$/", $address)) {
        printf("preg_match matches '%s'\n", $address);
} else {
        printf("preg_match !matches '%s'\n", $address);
}
if ( ereg("^[A-F]{2}([-:;,]?)([A-F]{2}\\1){4}[A-F]{2}$", $address)) {
        printf("ereg matches '%s'\n", $address);
} else {
        printf("ereg !matches '%s'\n", $address);
}
?>

output:
> preg_match matches 'AB:BC:CD:DE:EF:AF'
> ereg !matches 'AB:BC:CD:DE:EF:AF'

                                                - chad

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>