Skip to main content
June 25, 2023
Solved

Extract digits from string

  • June 25, 2023
  • 2 replies
  • 0 views

Hi Everyone,

I need to extract first four digits and last four digits from the given string. Like string is "sgdh567895dgh6787" then first four digits would be 5678 and last four are 6787. 

Can anyone please help me out?

Many Thanks!

    Best answer by stefanhelzle0001

    Find the list of available function in Appian here: https://docs.appian.com/suite/help/23.2/Appian_Functions.html

    I quickly put together a snippet:

    a!localVariables(
      local!value: "sgdh567895dgh6787",
      local!clean: cleanwith(local!value, "0123456789"),
      a!map(
        firstFour: left(local!clean, 4),
        lastFour: right(local!clean, 4)
      )
    )

    2 replies

    stefanhelzle0001
    Brainy
    June 25, 2023

    Find the list of available function in Appian here: https://docs.appian.com/suite/help/23.2/Appian_Functions.html

    I quickly put together a snippet:

    a!localVariables(
      local!value: "sgdh567895dgh6787",
      local!clean: cleanwith(local!value, "0123456789"),
      a!map(
        firstFour: left(local!clean, 4),
        lastFour: right(local!clean, 4)
      )
    )

    harshitb6843
    June 25, 2023

    If you numbers are going to be less than 9 digits, then you can also use tointeger() instead of cleanwith()