Re: Still an Almost working Regex

From: Date: Wed, 07 Mar 2001 04:41:03 +0000
Subject: Re: Still an Almost working Regex
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-42851@lists.php.net to get a copy of this message
In article <002d01c0a69a$ea2c9aa0$1e01a8c0@mu.com.au>, murray@mu.com.au ("Murray Shields") wrote: > $Status = (ereg("^(^[A-Za-z0-9` !@#$%&()=:;\"\'.?/^|{}-]*)(.*)$", > $String, > $List)); > > It is definitely working as expected. > > I need to add the square brackets [ ] to the above list of allowed > characters. According to the manual <http://php.net/manual/en/ref.regex.php>, "These functions all take a regular expression string as their first argument. PHP uses the POSIX extended regular expressions as defined by POSIX 1003.2. For a full description of POSIX regular expressions see the regex man pages included in the regex directory in the PHP distribution. It's in manpage format, so you'll want to do something along the lines of man /usr/local/src/regex/regex.7 in order to read it. " If you do not have access to manpages at the commandline, note that they are also widely republished on the web. A quick search on <http://www.google.com/search?q=posix+1003%2E2+regular+expressions> reveals: "A bracket expression is a list of characters enclosed in `[ ]'. It normally matches any single character from the list (but see below). If the list begins with `^', it matches any single character (but see below) not from the rest of the list." <snip> "To include a literal `]' in the list, make it the first character (following a possible `^')." -- CC

« previous php.general (#42851) next »