|  | Posted by Andy Jeffries on 05/22/06 22:06 
On Mon, 22 May 2006 13:47:39 -0500, Alan Little wrote:>>> In brackets, you only escape the [] characters themselves. Your
 >>> expression will allow the \ character in the string.
 >>
 >> I appreciate your enthusiasm but did you actually test this before
 >> trying to correct me ;-)
 >
 > Yes, I did. However, I checked with ereg(), which does allow the \
 > character, given the expression you posted earlier.
 
 Ah, ereg isn't standard, it's PHP dodgy partial regular expression engine.
 
 >> However, you do make the good point that you don't *need* to escape the
 >> -, I just do it for readability so there's no mistaking that I meant a
 >> literal dash and not part of a range that I forgot to complete.
 >
 > OK. I don't believe it's standard, however.
 
 AFAIK Perl is the standard for regular expression implementation and:
 
 $ cat test.pl
 #!/usr/bin/perl
 $string = "\\";
 if ($string =~ /[\-]/) {
 print "matches\n";
 }
 else {
 print "doesn't match\n";
 }
 $ ./test.pl
 doesn't match
 
 Cheers,
 
 
 Andy
 
 
 --
 Andy Jeffries MBCS CITP ZCE   | gPHPEdit Lead Developer
 http://www.gphpedit.org       | PHP editor for Gnome 2
 http://www.andyjeffries.co.uk | Personal site and photos
  Navigation: [Reply to this message] |