I have some trouble with filtering my HTTP-Connector result with RegEx.
It works just fine, as long as there are no NULL values in the response body.
Unfortunately I need to filter on some Keys, some objects may or may not have at all.
Then the Output also includes all NULL values, even if my RegEx looks for at least one character.
When I’m looking for “turn” I find the correct one but also all NULL Values…
Had to poke our resident RegEx person for some help on this one. He recommended using a json query over regex, in your case this would look like this: .[*OptionKeyDescription~turn]
A little more technical detail if you’re curious regexp is looking for the turn string in each of the OptionKeyDescription fields, not filter to just OptionKeyDescription that include turn. So when you pass it a string that doesn’t include turn, regexp will return null, which is what you are seeing.
Instead you want to filter the return to just cases where the string turn is included (which is what ~turn will do).
In this case json query might work, but this is a general issue with regex to me. The behaviour when adding regex directly on the Keys (no array) work as expected and as you mentioned
That seems to be only partially true. In the KnowledgeBase you show a similar case: KnowledgeBase Article
Blockquote Or, use it to select a specific item in an array that matches a rule. For example, the first object with an email value that starts with n. .[email:regexp(^N)]
In my case it does not return null where “turn” is not in the string. The objects without “turn” in the Value of “OptionKeyDescription” are filtered out correctly (cant upload a picture with the other Key-Values, because its company data), it shows all objects where the Key OptionKeyDescription does not exist and all objects where this Key includes “turn”.
The example with “turn” was just to keep it simple. This is with any regex when selecting from array.
By the way: Do you have any good recource for json query?
I have some troubles with what I found.
I landed on using the regexp() because regex is disabled in your JSON-Query settings and I was not able to get what I want wit JSON-Query alone.
for this example your JSON-query works fine.
But as mentioned this was a simplyfied example. I can’t search for Patterns e.g…
Every regexp() that I use to select from arrays will deliver all Objects without that Key and the matching ones, but not the existing without a match. This behaviour is still wrong to me.
The KnowledgeBase quote…
For example, the first object with an email value that starts with n. .[email:regexp(^N)]
…is not true. If there is an Object without any email, before, this would return ‘NULL’.
That behaviour makes this funktion useless to me…
on the following array would deliver Toms Objet with email: “NULL” because tom is before Norman and has no Mail.
If Tom had an email or tom wouldn’t exist it would deliver normans object.