Handling string variables and integers

Hi friends. I have a process in which I get the text of a string and save it in a variable. This string has the following format: “1 - 9” or “1 - 22” The final numbers vary and are not always constant. This variable is in string format and I make a substring because I’m only interested in the last digits (remaining " 9" or “22”). Is there any way to be able to save in another variable the numbers that are in the format “009” or “022” depending on the value that is there each time? Thanks

PD: In my process, when I make the substring of the string, it only saves the last two digits, but in the event that the string is “1 - 100” I would lose the real value that I want to save. Is there another way to do it?


You can use Split(“-”) function and split the string with the “-” sign
And then you can take the remaining value into the variable


Hafiz Mohammad Ahsan

1 Like

if I have the variable: var1 = “1 - 31”, how would it be?

You have to split it using Split function of string

It would be var1.Split("-"c)(1).tostring . Try it if it did not work then let me know


the request can be interpreted in different directions and so the case is not fully clear on what is needed.So have some building blocks

1 - 100 retrieval cases

filling up:


Otherwise just give us a clear sample input and the example of needed output, so we will work on this


The string that I get is obtained through gettext activity. image
But that string always varies, so what I want is to save the number and if it is from 2 to 9 I convert it to 009, if it is from 10 to 99 it is 010 or 099 and if it is 100 or greater then leave like 100.

is done here

System.Text.RegularExpressions.Regex.Replace(YourStringVar, “\d+”, Function (m) m.Value.PadLeft(3,"0"c))


Thank you all. You helped me and I was able to do it like this:
k = “1-23” —> a = k.split(" "c)(2).ToString —> c = a.ToString.PadLeft(3, "0"c) —> c =“023”

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.