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
  • Regexp will not work if you are not looking for a specific pattern. If a specific pattern then yes, use Regexp.
    There are many way to find integer value, as suggested by others. You can also try comparing with index of each element of your string/array. Choice should yours but based on your code performance. Thanks
  • 0
    Certified Lead Developer
    in reply to Amit Mishra

    A lot of these examples appear to show a fundamental misunderstanding of regex. If you'd like to do this using regex, you can use:

    fn!regexallmatches(
      "[0-9]+",
      "ABC 123"
    )

    Note that you'll have to choose between fn!regexallmatches and fn!regexfirstmatch depending on your data; the former returns a list of matches and the latter returns only the first match.

    If you'd like to see and/or test regexes, this tool is an excellent option and (as per the link) allows you to share and test regexes.

Reply
  • 0
    Certified Lead Developer
    in reply to Amit Mishra

    A lot of these examples appear to show a fundamental misunderstanding of regex. If you'd like to do this using regex, you can use:

    fn!regexallmatches(
      "[0-9]+",
      "ABC 123"
    )

    Note that you'll have to choose between fn!regexallmatches and fn!regexfirstmatch depending on your data; the former returns a list of matches and the latter returns only the first match.

    If you'd like to see and/or test regexes, this tool is an excellent option and (as per the link) allows you to share and test regexes.

Children
No Data