Solved

Extract number before decimal point

  • 31 October 2023
  • 6 replies
  • 112 views

Badge +10

I am trying to extract the number before a decimal point but keep it as an integer. I have found posts about how to extract numbers, but they all convert them to text. I can’t seem to come up with the needed Regex formula, but I guess there might be another solution?

I would like to convert something like 2023.0 to just 2023.

icon

Best answer by aak1 31 October 2023, 18:46

View original

6 replies

Userlevel 5
Badge +12

Are you trying to do this in a workflow or on a form?

Badge +10

On a workflow in NAC.

Userlevel 5
Badge +12

Try adding and configuring a “Apply a regular expression” action in your workflow with the following settings:

  • Input text = Your number data (form field, variable, etc.)
  • Operation = Extract
  • Pattern = (\d)(?=\.)
  • Ignore case = Yes
  • Store first result in = intDigit  (workflow variable of type Integer)

 

Badge +10

Thanks. It does strip out the “.0” but also only leaves the last number before the decimal point. So 2023.0 just becomes “3”.

Badge +10

I just realized that when I upgraded this workflow from O365 to NAC it converted that variable to a decimal. I just created a new integer variable and replaced the old variable. I’m a little slow sometimes :(

 

It is working now.

Userlevel 5
Badge +12

Sorry, I misread your original post.

Glad it is working now for you.

Reply