Re: Syntax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sep 22, 2015, at 5:32 AM, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote:

> 
> 
> On 22 September 2015 11:15:49 BST, Karl DeSaulniers <karl@xxxxxxxxxxxxxxx> wrote:
>> On Sep 22, 2015, at 3:36 AM, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx>
>> wrote:
>> 
>>> 
>>> 
>>> On 22 September 2015 07:33:14 BST, Karl DeSaulniers
>> <karl@xxxxxxxxxxxxxxx> 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
>> 
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> You wouldn't place it in your Regex, you use it to negate your call to preg_match:
> 
> !preg_match()


(slaps forehead)  ...I knew that dang it. too many hours awake. 


> 
> And get rid of the square brackets, they are for character matches, not string matches.


Yes, the square brackets didn't get edited in the email but are in my code. 
Sorry to make you repeat.

Thank you for your help!

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux