Re: Syntax

From: Date: Wed, 23 Sep 2015 05:11:13 +0000
Subject: Re: Syntax
Groups: php.general 
Request: Send a blank email to php-general+get-325132@lists.php.net to get a copy of this message
-------- Original message -------- From: Ashley Sheridan <ash@ashleysheridan.co.uk> Date: 09/22/2015 01:36 (GMT-08:00) To: Karl DeSaulniers <karl@designdrumm.com>, php-general@lists.php.net Subject: Re: [PHP] Syntax On 22 September 2015 07:33:14 BST, Karl DeSaulniers <karl@designdrumm.com> wrote: >Hello all, >Is this correct syntax? > >... >case preg_match("/^[-1|delete|hide|save]/", $MassOption) !== 1 : >... You should use something like this.  $str = "-1 save"; if ( preg_match("/^-1 (delete|hide|save)$/", $str ) === 1 ) {  echo "does match";} else {  echo "does not match";} > >I am needing to test against -1 (negative 1) and the words delete, >hide, and save. >$MassOption should not equal those. > >Best, > >Karl DeSaulniers >Design Drumm >http://designdrumm.com No, in regular expressions, the [ ] are for matching individual characters, not strings. You could instead perform a standard match in () and just negate the result of preg_match() with a !. -- Sent from my Android device with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#325132) next »