ereg() not working but preg_match() is...
Posted: Thu Jul 20, 2006 11:57 pm
i have this peice of code which does not seem to ever work ( the if statement is never true, thus the inner code never executes ).
if (ereg('<td\\sclass="vaText">\\s?([A-Z][A-Z\\s.]+)<', $subject, $regs)) {
echo "hello world";
}
but when i do:
if (preg_match('/<td\\sclass="vaText">\\s?([A-Z][A-Z\\s.]+)</', $subject, $regs)) {
echo "hello world";
}
then it will work...
If it helps at all, im using php 4.4.1 i belive
PS: also, for the second peice of code, how would i echo out the contents of the $reg array, i try
echo "$reg[1]";
but it comes up as blank, when i do sizeof on it, it comes back as 3. so it should be printing out whats in the () of the regexp.
any help would be great
if (ereg('<td\\sclass="vaText">\\s?([A-Z][A-Z\\s.]+)<', $subject, $regs)) {
echo "hello world";
}
but when i do:
if (preg_match('/<td\\sclass="vaText">\\s?([A-Z][A-Z\\s.]+)</', $subject, $regs)) {
echo "hello world";
}
then it will work...
If it helps at all, im using php 4.4.1 i belive
PS: also, for the second peice of code, how would i echo out the contents of the $reg array, i try
echo "$reg[1]";
but it comes up as blank, when i do sizeof on it, it comes back as 3. so it should be printing out whats in the () of the regexp.
any help would be great