Ad Widget

Collapse

Item.value regex

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • verde
    Member
    • Jul 2021
    • 39

    #1

    Item.value regex

    Hi,
    I'm a creating a trigger using the regsub to extract a part of {ITEM.VALUE} based on a match from a json string.
    I don't see that it could be achieved using some json function on the trigger configuration.

    The amount of item values is not fixed. It could bring two, three or more ids. The match is the id key from the item value:
    [{"id":30,"total":3,"installed":2,"available":1} ,{" id":10,"total":1,"installed":1,"available":0},{" id ":11,"total":7,"installed":5,"available":2}]



    i.e.:

    if the match is "30" it should obtain : {"id":30,"total":3,"installed":2,"available":1}
    if the match is "10" it should obtain : {"id":10,"total":1,"installed":1,"available":0}
    if the match is "11" it should obtain : {"id":11,"total":7,"installed":5,"available":2}


    I would use the match result in the trigger description

    The pattern used is :
    {{ITEM.VALUE}.regsub("{("id":11,.*.,.*.,*,.*)}", "\1" )}

    But it only works for the match in the last position. The match in the second position brings from that match until the last char. The match for the first position brings the whole string.

    Don't know if there's some trick that it could be used for this.

    Any help would be very appreciate it.

    Regards,
    Last edited by verde; 29-08-2021, 19:03.
Working...