Categories > TinyButStrong general >

if between

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: SunWuKung
Date: 2007-01-16
Time: 17:35

if between

Hi,
how do I specify a condition to check if a variable is between two numbers say 21 and 40? I see smaller/greater but I would need an AND to use those.

Thanks for the help.
SWK
By: SunWuKung
Date: 2007-01-16
Time: 18:12

Re: if between

I am also trying with a regexp, but this gives me the following error message: preg_match(): Unknown modifier '|'

[sc.am; if [val]~='(2[1-9])|(3[0-9])|40';then 'P'; else '']

Am I doing something wrong here?
Thx
SWK
By: ioguix
Date: 2007-01-16
Time: 18:43

Re: if between

Hello,

About matching with regex, I think you have enclose your regex between delimiters. You can see example by following the link given in the tbs manual : http://www.php.net/manual/en/function.preg-match.php

However, I'm sure there should be a better way to do it...

++
By: sheepy
Date: 2007-01-17
Time: 04:52

Re: if between

When using alternative match, you need to group the alternatives.  Try

if [val]~='((2[1-9])|(3[0-9])|40)'
By: SunWuKung
Date: 2007-01-17
Time: 12:13

Re: if between

Thanks for the regexp,
here is what I came up with for between in the meantime:

[sc.am; if [val]+-'40';then ''; if [val]+=-'21';then 'match'; else 'no match']

Thanks again.
SWK