How to determine if a value is a number in apigee - conditional-statements

http://apigee.com/docs/api-services/reference/conditions-reference
in the condition reference of apigee, how can you determine if a value is a valid number
<Condition> (myNumber = %d)</Condition>
<Condition> (myNumber ~~ "d")</Condition>
tried both but it is still working, any idea?
Edit:
thank you for taking time and looking at my query,
I found out the answer, it is
(myNumber ~~ "\d")
~~ <- means that it will evaluate the regex, and the quotes will contain the regex.

Might be best to ask this in the Apigee Community (https://community.apigee.com). In that post, please clarify what you're expecting to see and what's actually happening. For starters, you'll want to be sure the myNumber variable is available in the message payload.

Related

Regex negative lookahead not excluding required string

Good day
I've been trying to apply a specific exclusion in my regex_like function within Netezza SQL: regexp_like(trim(upper(a.MRCH_NME)),'\bMAKRO\s?(?!DEBTORS)','i')
Unfortunately I can't get the expression to exclude the "DEBTORS". Would anyone be able to assist me in finding my mistake?
Thank you.
Here is one quick fix to your pattern:
\bMAKRO\s(?!DEBTORS)
Code:
regexp_like(trim(upper(a.MRCH_NME)),'\bMAKRO\s(?!DEBTORS)','i')
The reason your current pattern is allowing MAKRO DEBTORS WOODME to pass is that it can take the \s as optional, then assert that DEBTORS does not immediately follow MAKRO.
Demo
Edit:
You could also rewrite your negative lookahead slightly to this:
\bMAKRO(?!\s?DEBTORS)

documentation of splunk "ifnull" function?

We're using the ifnull function in one of our Splunk queries (yes, ifnull not isnull), and I wanted to look up the logic just to be sure, but I can't find it documented anywhere.
It is referenced in a few spots:
SPL data types and clauses
Eval
Where
But I can't find a definition/explanation anywhere on what it actually does. Google seems to be of no help either (constantly wants to redirect me to isnull).
In particular it's also not listed in "common evaluation functions".
Can anyone point me to some documentation about ifnull?
TL;DR; it's an alias for coalesce
Wow, it really is hidden! I managed to find it on my local instance here: ./etc/system/default/searchbnf.conf
example4 = coalesce(null(), "Returned value", null())
comment4 = Takes any number of arguments and returns the first value that is not null. The ifnull function does the exact same thing, so both names are acceptable.

Whats wrong with this expression?

Comments: Switch(((IIf(([qty_req]-[qty_on_hand])<0,0,([qty_req]-[qty_on_hand])))=0) And ((([qty_on_hand]-[qty_req])/[qty_req])<=0.2),"Please check manually")
I have been struggling with this expression for too long. I keep getting the error "This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables." I've tried breaking down the expression to see if there was a bracket I the wrong place but I can't figure this out.
Note: The word "Comments" is just the field name (I primarily use the Design View in MS Access).
Update - The goal behind this is to eventually add more conditions to this switch statement, but this first one isn't working so that's why it seems like it doesn't make sense to use a Switch. Also, in pseudo code, this is what the intention of this expression is:
Switch([TransferQTY]=0 And [Req is within 20% of Inventory], "Please check manually")
In regards to the first IIF statement:
IIf([Req-Inventory is negative, that means that we have enough on hand and don't need to send],0, [Req-Inventory])
I think it's simply a check like this:
IIf([qty_req]-[qty_on_hand]<0 And ([qty_on_hand]-[qty_req])/[qty_req]<=0.2,"Please check manually","") AS Comments
The first IIF is just strangely built and has some redundancy to it. The second might give you strange answers because you don't have parans around your numerator. As it's written it could be simplified to:
As for the first IIF, you stated
"IIf([Req-Inventory is negative, that means that we have enough on
hand and don't need to send],0, [Req-Inventory])"
in the context of the switch (psuedo-coded):
Switch([TransferQTY]=0 And [Req is within 20% of Inventory], "Please
check manually")
This is basically saying "If the quantity requested minus thequantity on hand is less than or equal to 0", so instead of an IIF to do the "Less than or equal to" bit, just use <=:
Switch(((qty_req - qty_on_hand) <= 0) AND (((qty_on_hand - qty_req)/qty_req) <= 0.2), "Please Check Manually")
This will work better because Access is balking about the complexity. This dramatically reduces the complexity and accomplishes the same thing.
Also, I've gone a little heavy handed with the parantheses here. You could remove the ones that delineate each of the conditions that the AND function is evaluating and it would be fine.
I've removed the bit here about not using switch that was in a previous version of this answer since OP stated that switch() will be used after this bit starts working.

Can "number += 1" be explained intuitively/mnemonically?

Previous research
In several languages (perl, python, php, etc.) there is the <value> += <increment> operator**, which increments a <value> by adding <increment> to it. This can be used in a for loop, which will cumulatively add <increment> to <value> with each iteration. This saves having to type more explicitly (verbosely): <value> = <value> + <increment>.
The trouble with this operator is that one often forgets whether it was += or =+. I often learn I have typed it the wrong way later, the hard way.
I thought I would finally learn the intuition in this PHP tutorial (01:35), but he fumbles it.
Question
Is there an intuitive "in plain english" way of explaining why it is += instead of =+ or was it some convention that was arbitrarily set once upon a time?
If "Yes" to the above, then what is this intuitive way of explaining why it is +=?
** Please let me know in comments what this operator is formally known as.
Putting the non-equals sign before the equals sign reduces perceived ambiguity: a-=b can only mean "Decrement a by b", but a=-b could also mean "Set a to the negated value of b".
This wouldn't technically be ambiguous, since the C parsing rules are clear that token consumption is greedy (that is, if =- were an operator, the parser would always prefer to parse it as =- rather than = -), but clearly it would have been ambiguous from a readability standpoint.
I don't know history behind this one, but I've always just thought of it as
+= "add it first, assign it next". So if you're in a read left to right culture (english) then this makes sense as adding comes first, then assigning comes next.
Please see Sneftel's answer for a very good technical reason.

Querystring does not return all values

I've searched all over the web for an answer and I can't see anybody with the same or similar problem (which surprises me certainly, so I certainly suspect it's me somehow).
When I do a
Request.Querystring("key1")
Request.Querystring("key2")
the system doesn't seem to parse the second ?/value out but treats it as if key1 was all one string, e.g. http://www.example.com/default.aspx?key1=abc?key2=def returns abc?key2=def ...as if it completely ignores or doesn't parse out the second (or other if more) key/value pairs.
Wondering if anyone has any ideas?
You should only have one ? in your request, following separators should be &
regards
/t
don't use this
http://www.example.com/default.aspx?key1=abc?key2=def
QueryStrings start with ? however each other token is delmited by &
http://www.example.com/default.aspx?key1=abc&key2=def
This will yield the proper results when you use
Request.Querystring("key2")