Extract Function

Certified Associate Developer

Hi All I have requirement to get the values between  square brackets iam achieving it with the help of  extract function but when i was trying to insert the brackets after entering value and if my text value has uneven number of brackets it is erroring out

  

can you suggest is their any other alternate way to achieve this 

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Associate Developer
    in reply to Stewart Burchell

    a!localVariables(
    local!datacontent: fn!char(
    fn!code(ri!text)
    ),
    local!sum: a!forEach(
    items: local!datacontent,
    expression: a!match(
    value: fv!item,
    equals: "[",
    then: 1,
    equals: "]",
    then: - 1,
    default: 0
    ),

    ),
    local!totalSum: fn!sum(local!sum),
    local!statusCode: if(local!totalSum = 0, 1, 0),
    local!result: union(
    if(
    local!totalSum = 0,
    fn!extract(
    ri!text,
    "[",
    "]"
    ),
    ""
    ),
    touniformstring({})
    ),
    {
    if(
    local!statusCode = 1,
    "",
    "Number of open square brackets and close square brackets must be equal"
    ),
    if(
    a!forEach(
    items: local!result,
    expression: find("[", fv!item)
    ),
    "No square brackets is allowed between [ and ]",
    ""
    )
    }
    )   in addition to your solution just added  find("[", fv!item) this to validation to prevent "[" in between open and close square brackets Thanks Stewart and Mike for you time and suggestion

Children
No Data