ID: 24242 User updated by: madsen at sjovedyr dot dk Reported By: madsen at sjovedyr dot dk -Status: Open +Status: Bogus Bug Type: Regexps related Operating System: Debian Linux (Woody) Unstable PHP Version: 4.3.2 New Comment:
Found the solution... Appearantly '[' and ']' doesn't need to be escaped (inconsistency?), but they have to be the first characters in the list of matches.... Previous Comments: ------------------------------------------------------------------------ [2003-06-18 06:05:43] madsen at sjovedyr dot dk Description: ------------ Attempting to use ereg() for matching the date from an Apache error_log fails, when using the pattern: "^\[([^\]]*)\]" Intention of the pattern explained (in case I just can't see the error in it): ^\[ - Require first char in string to be a litteral '['. ([^\]]*) - Match any number of chars that is NOT ']'. \] - Match a litteral ']' When using this pattern in ereg(), like: ereg("^\[([^\]]*)\]", $string, $regs); $regs has returned empty, when printed by a print_r(); But then if I use "^\[(.*)\]" as my pattern, I get something in $regs, not the right match, since it then runs in 'greedy mode', and catches what's between *(* and *)*: [*(*Aug 25 2002 14:53:32] [error] [client: 88.99.111.222*)*] ... It's really confusing me... If this is not a bug I apologise, but I think I have taken every form of action required before reporting this as a bug. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24242&edit=1