ga***@elak.org (Stefan Gangefors) writes:
I'm trying to figure out what I'm doing wrong when using ereg().
This is my regexp:
ereg("^[\]]$", "]");
and that does'n work, but this does:
ereg("^[\[]$", "[");
How come I can match left bracket but not the right?
am I using the esc char correctly?
The "Regular Expression Functions (POSIX Extended)" chapter of the
PHP manual directs readers to the regex manual page in the PHP
source code. That manual page says:
"To include a literal `]' in the list, make it the first character
(following a possible `^'). To include a literal `-', make it the
first or last character, or the second end- point of a range. To
use a literal `-' as the first end- point of a range, enclose it
in `[.' and `.]' to make it a collating element (see below). With
the exception of these and some combinations using `[' (see next
paragraphs), all other special characters, including `\', lose their
special significance within a bracket expression."
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/