Re: Syntax
| From: | Karl DeSaulniers | Date: | Tue, 22 Sep 2015 10:15:49 +0000 |
| Subject: | Re: Syntax | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325129@lists.php.net to get a copy of this message | ||
On Sep 22, 2015, at 3:36 AM, Ashley Sheridan <ash@ashleysheridan.co.uk> wrote:
>
>
> 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 :
>> ...
>>
>> 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 !.
>
Thank you Ashley for responding.
I did finally come across the () however the ! eluded me.
Wherein do I place the ! mark? Like so?
preg_match("/^![-1|delete|hide|save]/", $MassOption) !== false
or just?
preg_match("/^![-1|delete|hide|save]/", $MassOption)
TIA
Best,
Karl DeSaulniers
Design Drumm
http://designdrumm.com