Regexp function to extract numbers

Hello, 

Does Appian have any inbuilt function to extract numbers only from a text string?

Eg: If the string field is "ABC 123" then how to get the value of 123

 

Thanks, 

Rohit 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Hi i believe cleanwith(..., ....) function is the best option here for your case, because of following reasons:

    1. When you use tointeger(...) text will be converted to their respective Integer, but when you have some special characters, it will return null as it's response. For example: tointeger("a.@1apllr2-_3,,.../ab") -> Returns -> null

    2. When you go for regexallmatches() you have similar kind of issues and in order to resolve that, you need to make the use of wildcard characters/escape sequence syntax. Below code snippet show the problem with regexallmatches()

    load(
    local!string:"a.@1apllr2-_3,,.../ab",
    regexallmatches(
    "1234567890",
    local!string
    )
    )

    Hence i recommend better to go for cleanwith(..., ....)


    Hope it will help you to choose the best option for your scenario.
Reply
  • 0
    Certified Lead Developer
    Hi i believe cleanwith(..., ....) function is the best option here for your case, because of following reasons:

    1. When you use tointeger(...) text will be converted to their respective Integer, but when you have some special characters, it will return null as it's response. For example: tointeger("a.@1apllr2-_3,,.../ab") -> Returns -> null

    2. When you go for regexallmatches() you have similar kind of issues and in order to resolve that, you need to make the use of wildcard characters/escape sequence syntax. Below code snippet show the problem with regexallmatches()

    load(
    local!string:"a.@1apllr2-_3,,.../ab",
    regexallmatches(
    "1234567890",
    local!string
    )
    )

    Hence i recommend better to go for cleanwith(..., ....)


    Hope it will help you to choose the best option for your scenario.
Children
No Data